🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2787

-Zp Option Problem

#2787
From: Roman Roberto Luzzi
Date: Wed, 22 May 1991 10:33
61 lines
2288 bytes


Hello:

  I have problems with the package option -Zp of the Microsoft C 6.0 
Compiler when I pass structures to functions as value parameters.
When the structures have odd size, in the calling to the function 
the compiler puts in the stack the structure correctly (with odd size), 
but the compiler defines the target function parameters with even size 
(it doesn't pack the parameters in byte boundaries).
The simple code below is an example of the problem:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct OddName {
        unsigned int present;
	char value[9];
	} n1, n2, n3;

static void 
teststack(struct OddName nx, struct OddName ny, struct OddName nz);

static void
teststack(struct OddName nx, struct OddName ny, struct OddName nz)
{
 printf("STACK TEST Init...\n");
 printf("Value 1 Received %s\n",nx.value);
 printf("Value 2 Received %s\n",ny.value);
 printf("Value 3 Received %s\n",nz.value);
 printf("STACK TEST Finish.\n");
}

void main ()
{
 strcpy(n1.value,"1234");
 strcpy(n2.value,"1234");
 strcpy(n3.value,"1234");
 teststack(n1, n2 ,n3);
 exit(0);
}

This simple program was compiled with:  CL -AS -Zp -W4 test.c
and its output was:
  STACK TEST Init...
  Value 1 Received 1234
  Value 2 Received 234
  Value 3 Received 34
  STACK TEST Finish.


As you can see, the function parameters have a size of 12 bytes (-Zp doesn't 
work!!), and the variables have a size of 11 bytes (correct -Zp package).
Obviously, this same program works correctly without the -Zp option, but 
it is necessary in Windows environment.

Has anyone had this problem prior? Thanks in advance.

		       Roman Luzzi.(rluzzi@dit.upm.es)
Technical Details
Message-ID: <RLUZZI.91May22123346@greco.dit.upm.es>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!goya!goya!rluzzi

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!goya!goya!rluzzi
From: rluzzi@dit.upm.es (Roman Roberto Luzzi)
Newsgroups: comp.windows.ms.programmer
Subject: -Zp Option Problem
Message-ID: <RLUZZI.91May22123346@greco.dit.upm.es>
Date: 22 May 91 10:33:46 GMT
Sender: @dit.upm.es
Distribution: comp
Organization: Dept. Ingenieria de Sistemas Telematicos, UPM, Madrid, Spain.
Lines: 61
Nntp-Posting-Host: greco.dit.upm.es
Posting-Front-End: GNU Emacs 18.41.36 of Wed Jun 15 1988 on greco (berkeley-unix)