ext/fileinfo/libmagic/apprentice.c", line 2195: error: syntax error

php.internals

Dennis Clarke

9 years ago
I tried the php-install mail list but saw no reply thus I will try here. While attempting a build of 7.0.11 I was presented with : "/usr/local/build/php-7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c", line 2195: error: syntax error before or at: struct "/usr/local/build/php-7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c", line 2209: error: syntax error before or at: struct cc: acomp failed for /usr/local/build/php-7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c gmake: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1 The problem appears to be in a strange placement of the keyword "struct" : 2189 private int 2190 parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line) 2191 { 2192 struct magic *m = &me->mp[0]; 2193 2194 return parse_extra(ms, me, line, 2195 CAST(off_t, offsetof(struct magic, apple)), 2196 sizeof(m->apple), "APPLE", "!+-./", 0); 2197 } 2198 also 2203 private int 2204 parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line) 2205 { 2206 struct magic *m = &me->mp[0]; 2207 2208 return parse_extra(ms, me, line, 2209 CAST(zend_off_t, offsetof(struct magic, mimetype)), 2210 sizeof(m->mimetype), "MIME", "+-/.", 1); 2211 } 2212 Not sure where the definition of "offsetof()" is located but something seems clearly not C compliant here. So this is using the Oracle Studio 12.5 compiler tools on a big old SPARC box running Solaris 10. Any input would be appreciated. The cflags were permissive and allowed for transition type elements as I note that C99 with strict compliance will fail horribly. The configure stage was reasonably clean also. In any case .. any input would be greatly appreciated. Dennis

Christoph Becker

9 years ago
On 05.10.2016 at 16:59, Dennis Clarke wrote:
> I tried the php-install mail list but saw no reply thus I will try here. > > > While attempting a build of 7.0.11 I was presented with : > > "/usr/local/build/php-7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c", > > line 2195: error: syntax error before or at: struct > "/usr/local/build/php-7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c", > > line 2209: error: syntax error before or at: struct > cc: acomp failed for > /usr/local/build/php-7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c > > gmake: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1 > > > The problem appears to be in a strange placement of the keyword "struct" : > > 2189 private int > 2190 parse_apple(struct magic_set *ms, struct magic_entry *me, const > char *line) > 2191 { > 2192 struct magic *m = &me->mp[0]; > 2193 > 2194 return parse_extra(ms, me, line, > 2195 CAST(off_t, offsetof(struct magic, apple)), > 2196 sizeof(m->apple), "APPLE", "!+-./", 0); > 2197 } > 2198 > > also > > 2203 private int > 2204 parse_mime(struct magic_set *ms, struct magic_entry *me, const > char *line) > 2205 { > 2206 struct magic *m = &me->mp[0]; > 2207 > 2208 return parse_extra(ms, me, line, > 2209 CAST(zend_off_t, offsetof(struct magic, mimetype)), > 2210 sizeof(m->mimetype), "MIME", "+-/.", 1); > 2211 } > 2212 > > > Not sure where the definition of "offsetof()" is located but something > seems clearly not C compliant here. > > So this is using the Oracle Studio 12.5 compiler tools on a big old > SPARC box running Solaris 10. Any input would be appreciated. The cflags > were permissive and allowed for transition type elements as I note that > C99 with strict compliance will fail horribly. The configure stage was > reasonably clean also. > > In any case .. any input would be greatly appreciated.
offsetof() is supposed to be declared in <stddef.h>[1]. Perhaps it would need a typedef for your system? [1] <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
-- Christoph M. Becker

Dennis Clarke

9 years ago
>> Not sure where the definition of "offsetof()" is located but something >> seems clearly not C compliant here. >> >> So this is using the Oracle Studio 12.5 compiler tools on a big old >> SPARC box running Solaris 10. Any input would be appreciated. The cflags >> were permissive and allowed for transition type elements as I note that >> C99 with strict compliance will fail horribly. The configure stage was >> reasonably clean also. >> >> In any case .. any input would be greatly appreciated. > > offsetof() is supposed to be declared in <stddef.h>[1]. Perhaps it > would need a typedef for your system?
hrmmm ... I don't think that is the issue here. Definately have that header and this is a POSIX compliant system for sure. In fact, from my $HOME/.profile : # # ident "@(#)local.profile 1.10 Dec 11 20:25:36 GMT 2014 ccode" stty istrip MAIL=/usr/mail/${LOGNAME:?} # Standards, Environments, and Macros fully supported within UNIX # --------------------------------------------------------------- # This system supports IEEE Std 1003.1 and IEEE Std 1003.2, # commonly known as POSIX.1 and POSIX.2, respectively. # Solaris 10 also supports the X/Open Common Applications # Environment (CAE) Portability Guide Issue 3 (XPG3) and Issue # 4 (XPG4); Single UNIX Specification (SUS, also known as # XPG4v2); Single UNIX Specification, Version 2 (SUSv2); and # Single UNIX Specification, Version 3 (SUSv3). Both XPG4 and # SUS include Networking Services Issue 4 (XNS4). SUSv2 # includes Networking Services Issue 5 (XNS5). # # This is a fully LP64 (64-bit) environment and is fully # compliant with The Open Group's UNIX 03 Product Standard. # An application that wants to use standard-conforming utili- # tues must set the PATH (sh(1) or ksh(1)) or path (csh(1)) # environment variable to specify the directories listed below # in the order specified to get the appropriate utilities: # # POSIX.1-2001, SUSv3 # # 1. /usr/xpg6/bin # # 2. /usr/xpg4/bin # # 3. /usr/ccs/bin # # 4. /usr/bin # # 5. directory containing binaries for your compiler # # 6. other directories containing binaries needed by # the application # # When an application uses execlp() or execvp() (see exec(2)) # to execute a shell file, or uses system(3C), the shell used # to interpret the shell file depends on the standard to which # the caller conforms. # # See full details in standards(5) and at The OPEN Group(tm) or # Oracle web sites. # # --------------------------------------------------------------- PATH=/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/jdk/latest/bin:/usr/local/ssl/bin:/usr/bin:/opt/developerstudio12.5/bin:/sbin:/bin:/usr/sbin:/usr/dt/bin:/usr/openwin/bin:/usr/X11/bin:/opt/schily/bin:/usr/local/texlive/2012/bin/sparc-solaris export PATH pretty sure I can carve that back to just items 1 to 6 above and use C99 compiler /opt/developerstudio12.5/bin/c99 and cflags options -Xc to be really really strict. I think the error message is about the use of the "struct" keyword there.
> [1] <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
yep .. know it well. I may just have to change the sources a wee bit and see what happens here. Maybe this is a GCC GNUism that snuck in. dc

Bishop Bettini

9 years ago
On Wed, Oct 5, 2016 at 12:51 PM, Dennis Clarke <dclarke@blastwave.org> wrote:
> > Not sure where the definition of "offsetof()" is located but something >>> seems clearly not C compliant here. >>> >>> So this is using the Oracle Studio 12.5 compiler tools on a big old >>> SPARC box running Solaris 10. Any input would be appreciated. The cflags >>> were permissive and allowed for transition type elements as I note that >>> C99 with strict compliance will fail horribly. The configure stage was >>> reasonably clean also. >>> >>> In any case .. any input would be greatly appreciated. >>> >> >> offsetof() is supposed to be declared in <stddef.h>[1]. Perhaps it >> would need a typedef for your system? >> > > hrmmm ... I don't think that is the issue here. Definately have that > header and this is a POSIX compliant system for sure. In fact, from my > $HOME/.profile : > > pretty sure I can carve that back to just items 1 to 6 above and use C99 > compiler /opt/developerstudio12.5/bin/c99 and cflags options -Xc to be > really really strict. > > I think the error message is about the use of the "struct" keyword there. > > [1] <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ >> stddef.h.html> >> > > yep .. know it well. > > I may just have to change the sources a wee bit and see what happens here. > Maybe this is a GCC GNUism that snuck in.
Commit 2181ed2 <https://github.com/php/php-src/commit/2181ed2e2ab0c137d843e2ebea1d7d92e7d9b759#diff-8f841b91bdb2e623187010251ec474ba> introduced the change, and I note that <stddef.h> is config guarded by ifdef HAVE_STDDEF_H. So, perhaps check your configured values to see if that header is detected properly.

Anatol Belski

9 years ago
> -----Original Message----- > From: Dennis Clarke [mailto:dclarke@blastwave.org] > Sent: Wednesday, October 5, 2016 5:00 PM > To: internals@lists.php.net > Subject: [PHP-DEV] ext/fileinfo/libmagic/apprentice.c", line 2195: error: syntax > error > > > I tried the php-install mail list but saw no reply thus I will try here. > > > While attempting a build of 7.0.11 I was presented with : > > "/usr/local/build/php- > 7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c", > > line 2195: error: syntax error before or at: struct "/usr/local/build/php- > 7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c", > > line 2209: error: syntax error before or at: struct > cc: acomp failed for > /usr/local/build/php- > 7.0.11_SunOS5.10_sparcv9.001/ext/fileinfo/libmagic/apprentice.c > gmake: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1 > > > The problem appears to be in a strange placement of the keyword "struct" : >
What is strange with the struct? Looks more like there is some missing some datatype or macro.
> 2189 private int > 2190 parse_apple(struct magic_set *ms, struct magic_entry *me, const char > *line) > 2191 { > 2192 struct magic *m = &me->mp[0]; > 2193 > 2194 return parse_extra(ms, me, line, > 2195 CAST(off_t, offsetof(struct magic, apple)), > 2196 sizeof(m->apple), "APPLE", "!+-./", 0); > 2197 } > 2198 > > also > > 2203 private int > 2204 parse_mime(struct magic_set *ms, struct magic_entry *me, const char > *line) > 2205 { > 2206 struct magic *m = &me->mp[0]; > 2207 > 2208 return parse_extra(ms, me, line, > 2209 CAST(zend_off_t, offsetof(struct magic, mimetype)), > 2210 sizeof(m->mimetype), "MIME", "+-/.", 1); > 2211 } > 2212 > > > Not sure where the definition of "offsetof()" is located but something seems > clearly not C compliant here. >
Just to be sure. If you include stddef.h directly, does it fix it? Normally stddef.h were included from php.h already, It could make sense otherwise to generate the preprocessed source and check the exact code produced. If you see something strange, it might be helpful to ifdef out some piece of code to check it were the cause. Otherwise, quite hard to guess what's happening, but likely some missing macro or datatype. Regards Anatol