hhd0@GTE.COM (Horace Dediu) (09/20/90)
While doing a compile, I get the following errors: cc -g -I. -Dvax -DUSE_VARARGS=1 -DUSE_PROTOTYPES=0 -c tif_dir.c 803 | { if (((tif)->tif_dir.td_fieldsset[FIELD_GRAYRESPONSECURVE/ ...........................................a.....b................. a - 1506-045: (S) Undeclared variable. b - 1506-046: (S) Syntax error. and many more of the same character. The equivalent line of code (803) in tif_dir.c is: CleanupField(GRAYRESPONSECURVE, td_grayresponsecurve); where #define CleanupField(field, member) { \ if (TIFFFieldSet(tif, CAT(FIELD_,field))) { \ free((char *)td->member); \ td->member = 0; \ } \ } and #define TIFFFieldSet(tif, field) \ ((tif)->tif_dir.td_fieldsset[field/32] & (1L<<(field&0x1f))) So what we have here is a double macro substitution. The compiler does not handle this properly. I found that the code compiled fine on VAX and MIPS architectures (plus many others the author of the code has ported to--SG, Sun, Tahoe, etc.). Is the problem with the compiler or is there some new convention that no such substitutions are allowed? I suspect the former, since the substitutions are performed (see the original error message). -- Horace Dediu \"That's the nature of research--you don't know |GTE Laboratories (617) 466-4111\ what in hell you're doing." `Doc' Edgerton |40 Sylvan Road UUCP: ...!harvard!bunny!hhd0................................|Waltham, MA 02254 Internet: hhd0@gte.com or hhd0%gte.com@relay.cs.net..........|U. S. A.
frank@gremlin.austin.ibm.com (Frank Feuerbacher) (09/20/90)
> Is the problem with the compiler or is there some new convention that no such > substitutions are allowed? I hope that you have taken the time to report this problem to IBM. The sooner they know about it, the sooner you will get it fixed. Disclaimer: I don't speak for my employer and they don't speak for me.
jim@segue.segue.com (Jim Balter) (09/21/90)
In article <9756@bunny.GTE.COM> hhd0@GTE.COM (Horace Dediu) writes:
[ problems with macros ]
The problem is most likely in your CAT macro, which probably looks like
#define CAT(a,b) a/**/b
instead you should use
#ifdef __STDC__
#define CAT(a,b) a##b
#else
#define IDENT(x)x
#define CAT(a,b)IDENT(a)b
#endif
dwatts@ki.UUCP (Dan Watts) (09/21/90)
In article <9756@bunny.GTE.COM> hhd0@GTE.COM (Horace Dediu) writes: > ... code example deleted ... >Is the problem with the compiler or is there some new convention that no such >substitutions are allowed? I suspect the former, since the substitutions >are performed (see the original error message). >-- >Horace Dediu \"That's the nature of research--you don't know |GTE Laboratories >(617) 466-4111\ what in hell you're doing." `Doc' Edgerton |40 Sylvan Road >UUCP: ...!harvard!bunny!hhd0................................|Waltham, MA 02254 >Internet: hhd0@gte.com or hhd0%gte.com@relay.cs.net..........|U. S. A. If the above examples are correct, you've got spaces in the #define of the function macro. That's not allowed as far as I know. ie: #define CleanupField(field, member) { \ ^-- No space! Try removing the spaces from the macro definitions, and see what happens. -- ##################################################################### # CompuServe: >INTERNET:uunet.UU.NET!ki!dwatts Dan Watts # # UUCP : ...!{uunet | wgc386}!ki!dwatts Ki Research, Inc. # ############### New Dimensions In Network Connectivity ##############
madd@world.std.com (jim frost) (09/22/90)
jim@segue.segue.com (Jim Balter) writes: >In article <9756@bunny.GTE.COM> hhd0@GTE.COM (Horace Dediu) writes: >[ problems with macros ] >The problem is most likely in your CAT macro, which probably looks like >#define CAT(a,b) a/**/b >instead you should use >#ifdef __STDC__ >#define CAT(a,b) a##b >#else >#define IDENT(x)x >#define CAT(a,b)IDENT(a)b >#endif Yes, it depends on mode. In `cc' mode (-qlanglvl=extended) the old-style concatenation works. In `xlc' mode (ANSI) you must use the double-sharp. Thus you can write: #ifdef __STDC__ #define CAT(a,b) a##b #else #define CAT(a,b) a/**/b #endif jim frost saber software jimf@saber.com
jim@segue.segue.com (Jim Balter) (09/22/90)
In article <860@ki.UUCP> dwatts@ki.UUCP (Dan Watts) writes: >If the above examples are correct, you've got spaces in the >#define of the function macro. That's not allowed as far as >I know. ie: > >#define CleanupField(field, member) { \ > ^-- No space! If you RTFM, you may be disabused of this "knowledge".