Problem using LLVM 2.6

Discussion in 'Mac Programming' started by m85, Jan 23, 2010.

  1. m85 macrumors newbie

    Joined:
    Apr 8, 2008
    #1
    Here' what I did:

    • Downloaded the llvm 2.6 trunk from subversion using "svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm"
    • Configured with options "./configure --enable-optimized --enable-targets=x86_64"
    • Compiled it with "make -j2"
    • Installed it with "sudo make install"

    Now I can't compile the following source:

    Code:
    //
    // main.cpp
    //
    
    #include "llvm/LLVMContext.h"
    #include "llvm/Module.h"
    #include "llvm/Analysis/Verifier.h"
    #include "llvm/Support/IRBuilder.h"
    
    int main(void)
    {
    	return 0;
    }
    
    The error message I get is:
    # error "Must #define __STDC_LIMIT_MACROS before #including System/DataTypes.h"​

    I'm using an Intel Core 2 Duo Mac mini running Snow Leopard 10.6.2 and Xcode 3.2.1. I've tried including all the standard c++ library headers and making sure the search paths are correct. All my attempts have failed and I don't know what I'm doing wrong. Any help will be highly appreciated.
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Have you tried including limits.h?

    Before the LLVM includes that is.

    Edit: I'm just building it myself now to have a little play around with this as you got me interested.
     
  3. m85 thread starter macrumors newbie

    Joined:
    Apr 8, 2008
    #3
    I've tried both <limits.h> and <climits> to no avail.
     
  4. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #4
    If compiling from the command line add:

    Code:
    -D __STDC_LIMIT_MACROS=1
    to the g++ invocation.

    Alternately if being used from within Xcode add it to the project level settings. Search for 'GCC_PREPROCESSOR_DEFINITIONS' and add to it to the list of predefined macros:

    Code:
    __STDC_LIMIT_MACROS=1
     
  5. m85 thread starter macrumors newbie

    Joined:
    Apr 8, 2008
    #5
    Thank you. I also had to add __STDC_CONSTANT_MACROS=1 but it now compiles without any errors.
     

Share This Page