The following code: #define EMS_SYSTEM_NUM 12 #define EMS_INET_NUM 12 #define EMS_SUBSYS_NUM 2
typedef struct _ercb { struct _ercb *ercb_next; struct _ercb *ercb_prev; short ercb_did; short ercb_pad; } ems_rcb_t; typedef struct { ems_rcb_t *era_rcbp; unsigned era_ecount; /* event count */ unsigned era_bcount; /* byte count */ } ems_era_elem_t; static ems_era_elem_t ems_system[EMS_SYSTEM_NUM]; static ems_era_elem_t ems_inet[EMS_INET_NUM]; static ems_era_elem_t *ems_erm[] = {ems_system, ems_inet}; #if (sizeof(ems_erm) / sizeof(ems_era_elem_t *) != EMS_SUBSYS_NUM) #error "EMS registration matrix not up to date" #endif main() { } Compiled with the following command: gcc -c testcase.c Produces the following error: testcase.c:22:12: error: missing binary operator before token "(" Where line 22 is the #if and the second ( is the 12th character. The problem appears to be that the #if is parsing the line before the sizeof() is resolved to its manifest constant. This causes the parser to treat "sizeof" as a term and therefore to want a binary operator prior to the next term (in this case, the open paren). The fix is to resolve the sizeof first. I tried creating a #define for the sizeof() and replacing the defined value in the #if, but that produced exactly the same error. -- Summary: sizeof not handled by pre-processor in #if statement Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gmalkin at convergedaccess dot com GCC build triplet: 4.1.1 20060525 (Red Hat 4.1.1-1) GCC host triplet: i386-redhat-linux GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28823