[nycbug-talk] invalid type argument of '->'

Marc Spitzer mspitzer at gmail.com
Fri Mar 21 15:16:13 EDT 2008


On Fri, Mar 21, 2008 at 1:07 PM, Tim A. <techneck at goldenpath.org> wrote:
>
>  Tim A. wrote:
>  Michael Hernandez wrote:
>  On Mar 18, 2008, at 3:36 PM, Marc Spitzer wrote:
>
>  On Tue, Mar 18, 2008 at 2:46 PM, Michael Hernandez
> <mhernandez at techally.com> wrote:
>
>  I am trying to build the php5-spl port and I keep getting errors like
> this:
>
> /usr/ports/devel/php5-spl/work/php-5.2.5/ext/spl/php_spl.c:61: error:
> invalid type argument of `->'
>
> I looked at php_spl.c - I don't see what's wrong with it. The line
> is:
>
> spl_globals->autoload_extensions = NULL;
>
>
> Is that not valid code? Is my gcc just old? I'm running out of ideas
> here. Any help would be appreciated.
>
>  is spl_globals a pointer? Stupid question but it is complaining that
> it can not do a pointer dereference and access structure field.
>
> marc
>
>
>  To be quite honest, I'm not sure - I guess the PHP hackers might be
> too used to hacking in PHP and so their C is getting sloppy? Which
> isn't good since PHP is written in C, not PHP. :)
>
>
>
>  I just gave it a go. Installed from port just fine on 6.2.
>  Stupid question, but have you tried a portsnap?
>
>
>  I've been brushing up on my C lately. (btw, O'Reilly's C Pocket Reference
> is really good.)
>  So, Mark's pointer question got me curious and I thought I'd look it up.
>  It seems easy enough to determine.
>  Assuming we're in /usr/ports/devel/php5-spl
>  After you've at least attempted to install the port once, you should have a
> directory called work.
>  # find work -type f -exec grep -Hn spl_globals {} \;

if you want to poke around install the cscope port and use it, you *really*
want to do this.

>
>  Which indicates as I might have suspected, the answer is in php_spl.h
>
>  I think the following lines indicate that spl_globals is a pointer variable
> of type zend_spl_globals which would appear to be a pointer to a structure
> but I can't find where zend_spl_globals is implemented. It seems to not be
> in these source files.

check the installed php stuff, /usr/local/include

>
>  #ifdef ZTS
>  # define SPL_G(v) TSRMG(spl_globals_id, zend_spl_globals *, v)
>  extern int spl_globals_id;
>  #else
>  # define SPL_G(v) (spl_globals.v)
>  extern zend_spl_globals spl_globals;
>  #endif
>
>
>  I don't understand preprocessing though. So, I'm not sure exactly what the
> # define lines mean or how they work. (Coming up to that part).
>  Only thing I ever used those for were including standard headers.

C's macro preprocessor is not complicated, the above translates to:

if the thing ZTS is defined, somewhere above "#define ZTS 'something'
" was encountered do the first half otherwise do the second half.  And
if you want to do C and don't already have it get the current version
of K&R.  By do I mean put a chunk of text in the output file, as cpp
handles all the #commands and macro substitution.

Also keep in mind that the compiler, when it actually compiles,
expects one big file to munch on, #include for example does not tell
the compiler to look here so much to include this file in the current
one here.  I do not know if gcc actually does that, if you get it to
dump the cpp output it will tell you, but conceptually that is what C
does.

Happy hacking,

marc
-- 
Freedom is nothing but a chance to be better.
Albert Camus



More information about the talk mailing list