Thread: error using sizeof command when porting from Linux to Mac

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    2

    error using sizeof command when porting from Linux to Mac

    Hi,


    I'm trying to compile a version of the GENESIS neural simulator (The GENESIS Simulator) under Mac OS X Snow Leopard and using the latest version of XCode.


    I was successfully able to compile source code under Ubuntu Linux without any problems, but for some reason the following error starts appearing under Mac. The specific error I am receiving is as follows:


    Makefile output:
    cc -O2 -D__NO_MATH_INLINES -DBIGENDIAN -DBSD -DMacOSXDarwin -I. -I.. -I../shell -I../ss jump.c -c
    jump.c: In function ‘save_context’:
    jump.c:95: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigcontext’


    Output upon running cc independent of Makefile
    $ cc jump.c -c
    jump.c: In function ‘save_context’:
    jump.c:95: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigcontext’


    Thanks in advance for your help - I have been struggling with this for some time and any advice you could provide would be much appreciated.


    Briefly, here is the contents of jump.c near the site of the error.
    The complete file, jump.c, can be found at the following location:
    http://individual.utoronto.ca/davestansweb/jump.c

    #include <math.h>
    #include <stdio.h>
    #include <signal.h>
    #include <setjmp.h>
    #include <strings.h>

    #include "system_deps.h"

    #if (defined(i860) && !defined(paragon)) || (defined(Linux) && !defined(__GLIBC__)) || defined(CRAY) || defined(Cygwin)
    struct sigcontext
    {
    int xyzzy;
    };
    #endif

    extern jmp_buf main_context;

    #ifndef Solaris
    struct sigcontext sig_context;

    SIGTYPE
    save_context(sig,code,scp)
    int sig,code;
    struct sigcontext *scp;
    {
    /*
    ** save the context for later return
    */
    BCOPY(scp,&sig_context,sizeof(struct sigcontext)); <-- line 95
    }
    #endif

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    The problem is that the complete definition of struct sigcontext is not available. More than likely, there is just some header file you need to include. Unfortunately, I don't know which one.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Try #include <sys/signal.h>

    EDIT: Oh, and I don't think you want BIGENDIAN defined on Snow Leopard. Intel systems are little endian.
    Last edited by rags_to_riches; 11-06-2009 at 07:14 PM.

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    2
    Thanks a lot for the help guys. I actually fixed the problem, someone had found the solution and posted it on the GENESIS sourceforge website (SourceForge.net: GENESIS Neural Simulator: Topic: Mac OS X Leopard)

    Basically, the necessary step was to replace the line
    #if (defined(i860) && !defined(paragon)) || (defined(Linux) && !defined(__GLIBC__)) || defined(CRAY) || defined(Cygwin)

    by

    #if (defined(i860) && !defined(paragon)) || (defined(Linux) && !defined(__GLIBC__)) || defined(CRAY) || defined(Cygwin) || defined(MacOSXDarwin)


    This essentially removes the definition of sigcontext and, presumably, uses one of the definitions in the header files instead

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux To FreeBSD Porting Compile Problems
    By Geolingo in forum Linux Programming
    Replies: 4
    Last Post: 03-17-2004, 08:17 AM
  2. Linux Linux why Linux??
    By afreedboy in forum Tech Board
    Replies: 146
    Last Post: 01-21-2004, 06:27 PM
  3. Porting the NES emulator from DOS to Linux
    By billholm in forum Game Programming
    Replies: 14
    Last Post: 08-03-2002, 01:48 AM