Ptypes on OS X

Discussion in 'Mac Programming' started by JayMan8081, Dec 11, 2007.

  1. JayMan8081 macrumors regular

    Joined:
    Feb 20, 2007
    Location:
    Dayton, OH
    #1
    I'm trying to install the ptypes library under OS X 10.4.10. It will compile and install correctly, but when I go to use the library in any application I get the following errors:
    Code:
    /usr/include/ptypes.h:39: error: declaration of C function 'void* pt::pexchange(void**, void*)' conflicts with
    /usr/include/ptypes.h:38: error: previous declaration int pt::pexchange(int*, int)' here
    My version of gcc/g++ is:
    i686-apple-darwin8-gcc-4.0.1

    and the ptypes library can be found here:
    http://www.melikyan.com/ptypes/index.html

    Does anyone have any suggestions? It's a C++ library and when it built it used g++ so I'm not sure why it is giving error message pertaining to C.
     
  2. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #2
    C++ supports overloaded functions e.g. multiple versions of the same function with the same name, but different parameters while C doesn't.

    Are you building a non-C++/Objective-C++ app?
     
  3. JayMan8081 thread starter macrumors regular

    Joined:
    Feb 20, 2007
    Location:
    Dayton, OH
    #3
    Nope, it's another C++ library that uses ptypes. It's also compiling with g++ which is why I can't understand why this error is occurring. I can't duplicate this on any other Macs here at the office either. Previously this has worked but I did a format and clean re-install and since then I haven't been able to use the ptypes library. Very weird. So far google hasn't helped either! I also verified that there were no extern C { } statements anywhere in my code or the ptypes library code. Any suggestions would be greatly welcomed at this point.
     
  4. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #4
    That is weird.

    I compiled a small test driver (statically linked against libptype.a however) with the same version of g++ you mentioned and it compiles fine.

    Perhaps an #undef __cplusplus directive snuck into your code somewhere? Perhaps in some header file #include'd before ptypes.h?
     
  5. JayMan8081 thread starter macrumors regular

    Joined:
    Feb 20, 2007
    Location:
    Dayton, OH
    #5
    The error I'm getting is before it ever even gets to linking though. It won't even compile a source file that contains #include <ptypes.h> :(

    Hmm I will check on the #undef
     
  6. JayMan8081 thread starter macrumors regular

    Joined:
    Feb 20, 2007
    Location:
    Dayton, OH
    #6
    No luck yet. Didn't find any #undef in any of my code or in any of the ptypes code. Thanks for the suggestions though! I'd rather have something to try than sitting around.
     
  7. Gelfin macrumors 68020

    Gelfin

    Joined:
    Sep 18, 2001
    Location:
    Denver, CO
    #7
    Is the extension on your source file just .c instead of .cc or .cpp?
     
  8. JayMan8081 thread starter macrumors regular

    Joined:
    Feb 20, 2007
    Location:
    Dayton, OH
    #8
    Nope the extension is .cpp
     
  9. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #9
    What are compiler/linker flags are you using? What gcc/dyld environment variables are set?

    Are you getting any compiler errors before it complains about the multiple declarations?
     
  10. JayMan8081 thread starter macrumors regular

    Joined:
    Feb 20, 2007
    Location:
    Dayton, OH
    #10
    Using
    g++ -Wno-deprecated -I/usr/local/include -I../include
    to compile the source files.

    How do I find out what g++ and dyld env variables are set?

    Edit: Not getting any other compiler errors before it complains about the multiple declarations.
     
  11. JayMan8081 thread starter macrumors regular

    Joined:
    Feb 20, 2007
    Location:
    Dayton, OH
    #11
    I'm making some progress on this issue. If I leave the header files in /usr/include/ptypes/ and add an -I/usr/include/ptypes/ to my makefile then everything compiles fine. If I don't do that I get the errors as exhibited in my original post. Does anyone have any ideas? I know that before my reinstall I was able to compile projects with ptypes headers that were symlinked in /usr/include/ to their /usr/include/ptypes/ counterparts.
     

Share This Page