🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #195

Typedef Problem

#195
From: Andreas Burmester
Date: Sat, 28 Mar 1992 15:37
30 lines
1259 bytes
I'm dealing with a macro that also takes the type of a variable 
as parameter. To handle strings, I've typedefed

        typedef char CA[];

and ran into a problem, I could track down to these definitions:

(0)     CA s0 = "string 0";
(1)     CA s1 = "s1";
(2)     CA s2 = "this is string 2";

The translator passes (0) and (1), while at (2), it complains 
that "The initializer length exceeds the aggregate length." A 
closer inspection reveals already at (1) things go (at least for 
me) unexpected ways: There are 9 bytes allocated for s1 - note, 
that strlen(s0) == 9 !

It's obvious that, having processed (0), CA is 'retypdefed' to 
char CA[9]. Then the initializer of s2 is indeed too long.

Any comments?

Andreas

PSs.
     The compiler, to name it, is ECO-C, a pre-ANSI translator.

     I got my code work by using a CP (typedef char *CP) instead 
     of CA - of cause this is not what I originally meant.
Technical Details
Message-ID: <1992Mar28.153738.20577@mcshh.Hanse.DE>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!unido!drnhh!news.Hamburg.Germany.EU.net!buster

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!unido!drnhh!news.Hamburg.Germany.EU.net!buster
From: buster@mcshh.Hanse.DE (Andreas Burmester)
Newsgroups: comp.std.c
Subject: Typedef Problem
Message-ID: <1992Mar28.153738.20577@mcshh.Hanse.DE>
Date: 28 Mar 92 15:37:38 GMT
Organization: Point of Precense Hamburg
Lines: 30