C++ API for LLVM library generates too many warnings - c++

I am not sure if I am the only person or this is the problem of so many other people.
What I suffer from is that for an even simple code that includes LLVM headers regardless of what ever I write in my main function, I get too many warnings when I compile my codes with extra warnings:
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/IR/Instructions.h>
int main()
{
return 0;
}
I cat get these warnings by using either gcc or clang:
g++-9 -std=c++17 main.cpp -Wall -Wextra -I/usr/lib/llvm-9/include -c -o main.o
clang++-9 -std=c++17 main.cpp -Wall -Wextra -I/usr/lib/llvm-9/include -c -o main.o
They are mainly unused parameters:
In file included from /usr/lib/llvm-9/include/llvm/IR/ConstantFolder.h:20,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:24,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/IR/Constants.h: In member function ‘llvm::Value* llvm::ConstantData::handleOperandChangeImpl(llvm::Value*, llvm::Value*)’:
/usr/lib/llvm-9/include/llvm/IR/Constants.h:60:41: warning: unused parameter ‘From’ [-Wunused-parameter]
60 | Value *handleOperandChangeImpl(Value *From, Value *To) {
| ~~~~~~~^~~~
/usr/lib/llvm-9/include/llvm/IR/Constants.h:60:54: warning: unused parameter ‘To’ [-Wunused-parameter]
60 | Value *handleOperandChangeImpl(Value *From, Value *To) {
| ~~~~~~~^~
In file included from /usr/lib/llvm-9/include/llvm/IR/ConstantFolder.h:21,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:24,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/IR/InstrTypes.h: In member function ‘bool llvm::CallBase::isFnAttrDisallowedByOpBundle(llvm::StringRef) const’:
/usr/lib/llvm-9/include/llvm/IR/InstrTypes.h:1913:47: warning: unused parameter ‘S’ [-Wunused-parameter]
1913 | bool isFnAttrDisallowedByOpBundle(StringRef S) const {
| ~~~~~~~~~~^
In file included from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:33,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/IR/Instructions.h: In member function ‘llvm::BasicBlock* llvm::ReturnInst::getSuccessor(unsigned int) const’:
/usr/lib/llvm-9/include/llvm/IR/Instructions.h:2943:37: warning: unused parameter ‘idx’ [-Wunused-parameter]
2943 | BasicBlock *getSuccessor(unsigned idx) const {
| ~~~~~~~~~^~~
...
I just truncate these warnings. They are too many.
When I turn on the -Wconversion the problem becomes even worse:
In file included from /usr/lib/llvm-9/include/llvm/Support/MathExtras.h:17,
from /usr/lib/llvm-9/include/llvm/ADT/SmallVector.h:19,
from /usr/lib/llvm-9/include/llvm/ADT/STLExtras.h:20,
from /usr/lib/llvm-9/include/llvm/ADT/StringRef.h:12,
from /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:16,
from /usr/lib/llvm-9/include/llvm/Support/Host.h:16,
from /usr/lib/llvm-9/include/llvm/ADT/Hashing.h:48,
from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:18,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/Support/SwapByteOrder.h: In function ‘uint16_t llvm::sys::SwapByteOrder_16(uint16_t)’:
/usr/lib/llvm-9/include/llvm/Support/SwapByteOrder.h:36:23: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
36 | uint16_t Hi = value << 8;
| ~~~~~~^~~~
/usr/lib/llvm-9/include/llvm/Support/SwapByteOrder.h:37:23: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
37 | uint16_t Lo = value >> 8;
| ~~~~~~^~~~
In file included from /usr/lib/llvm-9/include/llvm/ADT/STLExtras.h:20,
from /usr/lib/llvm-9/include/llvm/ADT/StringRef.h:12,
from /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:16,
from /usr/lib/llvm-9/include/llvm/Support/Host.h:16,
from /usr/lib/llvm-9/include/llvm/ADT/Hashing.h:48,
from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12,
from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:18,
from main.cpp:1:
/usr/lib/llvm-9/include/llvm/ADT/SmallVector.h: In constructor ‘llvm::SmallVectorBase::SmallVectorBase(void*, size_t)’:
/usr/lib/llvm-9/include/llvm/ADT/SmallVector.h:45:35: warning: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘unsigned int’ may change value [-Wconversion]
45 | : BeginX(FirstEl), Capacity(TotalCapacity) {}
| ^~~~~~~~~~~~~
...
I get these warnings by clang too:
...
In file included from main.cpp:1:
In file included from /usr/lib/llvm-9/include/llvm/IR/IRBuilder.h:18:
In file included from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12:
/usr/lib/llvm-9/include/llvm/ADT/Hashing.h:190:15: warning: implicit conversion changes signedness: 'const char' to 'uint8_t' (aka 'unsigned char') [-Wsign-conversion]
uint8_t a = s[0];
~ ^~~~
/usr/lib/llvm-9/include/llvm/ADT/Hashing.h:191:15: warning: implicit conversion changes signedness: 'const char' to 'uint8_t' (aka 'unsigned char') [-Wsign-conversion]
uint8_t b = s[len >> 1];
~ ^~~~~~~~~~~
/usr/lib/llvm-9/include/llvm/ADT/Hashing.h:192:15: warning: implicit conversion changes signedness: 'const char' to 'uint8_t' (aka 'unsigned char') [-Wsign-conversion]
uint8_t c = s[len - 1];
~ ^~~~~~~~~~
...
This is just a MWE. Adding more headers, I can get other types of warnings such as
/usr/lib/llvm-9/include/llvm/ADT/Twine.h:232:16: warning: ‘<anonymous>.llvm::Twine::RHS.llvm::Twine::Child::twine’ may be used uninitialized in this function [-Wmaybe-uninitialized]
!RHS.twine->isBinary())
~~~~^~~~~
Now, I am wondering whether LLVM is written carelessly? I always turn on all warnings and make sure my application compiles with 0 warnings. When I do this while using LLVM all warnings of my code are burried under LLVM ones. I cannot easily see them. Usually the first advise from people is to turn off those warnings switches. I strictly resist that. I want to find them for my application. The alternative solution comes to my mind is to turn off these warnings only for LLVM but not for my application. Is this possible especially when using CMake?

The issue of system header files causing warnings is a common one. It is not really for me to judge whether the authors of those headers were "careless" or not, but there is a relatively simple way to disable specific warnings before including the 'offending' headers, then restore your 'full' warnings once they have been included.
For clang you can do this with various #pragma diagnostic ... lines, as shown in the following code snippet:
#if defined (__clang__)
#pragma clang diagnostic push // Saves current diagnostic settings
#pragma clang diagnostic ignored "-Wsign-conversion" // Ignore this warning
#pragma clang diagnostic ignored "-Wunused-parameter" // and this one...
// ... Add similar lines for other warnings you wish to disable
#endif
// Now include the 'offending' headers ...
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/IR/Instructions.h>
#if defined(__clang__)
#pragma clang diagnostic pop // Restores the saved settings
#endif
I don't have access to a GCC compiler but I believe very similar directives can be used: just substitute GCC for clang in the lines where that occurs. More information on such #pragma directives (for the GCC versions) can be found here.

It is dependent on your GCC/clang/OS installation. On Fedora 32 it works as expected out of the box with system gcc-10.2.1-1.fc32.x86_64 + system clang-10.0.0-2.fc32.x86_64:
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Verifier.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/IR/Instructions.h>
static void func(int val) {}
int main()
{
func(42);
return 0;
}
For GCC:
$ g++ -o stackoverflowllvmwarnings stackoverflowllvmwarnings.C $(llvm-config --cflags --libs) -std=c++17 -Wall -Wextra
stackoverflowllvmwarnings.C: In function ‘void func(int)’:
stackoverflowllvmwarnings.C:7:22: warning: unused parameter ‘val’ [-Wunused-parameter]
7 | static void func(int val) {}
| ~~~~^~~
$ _
For clang:
$ clang++ -o stackoverflowllvmwarnings stackoverflowllvmwarnings.C $(llvm-config --cflags --libs) -std=c++17 -Wall -Wextra
stackoverflowllvmwarnings.C:7:22: warning: unused parameter 'val' [-Wunused-parameter]
static void func(int val) {}
^
1 warning generated.
$ _
If you really want (you do not) the warnings even for system headers use Wsystem-headers (it works similar way both for gcc and clang):
$ clang++ -o stackoverflowllvmwarnings stackoverflowllvmwarnings.C $(llvm-config --cflags --libs) -std=c++17 -Wall -Wextra -Wsystem-headers
In file included from stackoverflowllvmwarnings.C:1:
In file included from /usr/include/llvm/IR/IRBuilder.h:17:
In file included from /usr/include/llvm-c/Types.h:17:
In file included from /usr/include/llvm-c/DataTypes.h:28:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/cmath:42:
/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/cpp_type_traits.h:110:12: warning: keyword '__is_void' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
struct __is_void
^
...

Related

MinGW-w64 compilation fails with nullptr_t

I'm trying to compile cpputest with MinGHW-w64 and it's failing because it can't find nullptr_t. The function that is failing is cpputest\src\CppUTest\SimpleString.cpp:StringFrom
SimpleString StringFrom(const nullptr_t value)
{
(void) value;
return "(null)";
}
I tried to manually compile this file with
C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\g++.exe -DCPPUTEST_HAVE_STRDUP=1 -DHAVE_CONFIG_H -D_TIMESPEC_DEFINED=1 #CMakeFiles/CppUTest.dir/includes_CXX.rsp -include "C:/git/tdd/cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h" -include "C:/git/tdd/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h" -std=c++11 -Wall -Wextra -pedantic -Wshadow -Wswitch-default -Wswitch-enum -Wconversion -Wsign-conversion -Wno-padded -Wno-long-long -Woverloaded-virtual -Wno-old-style-cast -Wno-c++14-compat -O2 -g -DNDEBUG -o CMakeFiles\CppUTest.dir\SimpleString.cpp.obj -c C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp
It fails with
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:565:31: error: 'nullptr_t' does not name a type
SimpleString StringFrom(const nullptr_t value)
^~~~~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:565:31: note: 'nullptr_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:32:1:
+#include <cstddef>
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:565:31:
SimpleString StringFrom(const nullptr_t value)
^~~~~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:565:14: error: redefinition of 'SimpleString StringFrom(int)'
SimpleString StringFrom(const nullptr_t value)
^~~~~~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:479:14: note: 'SimpleString StringFrom(int)' previously defined here
SimpleString StringFrom(int value)
^~~~~~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp: In function 'SimpleString StringFrom(cpputest_longlong)':
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:576:29: warning: unknown conversion type character 'l' in format [-Wformat=]
return StringFromFormat("%lld", value);
^~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:576:29: warning: too many arguments for format [-Wformat-extra-args]
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp: In function 'SimpleString StringFrom(cpputest_ulonglong)':
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:581:29: warning: unknown conversion type character 'l' in format [-Wformat=]
return StringFromFormat("%llu", value);
^~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:581:29: warning: too many arguments for format [-Wformat-extra-args]
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp: In function 'SimpleString HexStringFrom(cpputest_longlong)':
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:586:29: warning: unknown conversion type character 'l' in format [-Wformat=]
return StringFromFormat("%llx", value);
^~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:586:29: warning: too many arguments for format [-Wformat-extra-args]
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp: In function 'SimpleString HexStringFrom(cpputest_ulonglong)':
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:591:29: warning: unknown conversion type character 'l' in format [-Wformat=]
return StringFromFormat("%llx", value);
^~~~~~
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:591:29: warning: too many arguments for format [-Wformat-extra-args]
I tried the naive solution of including cstddef:
#include <cstddef>
SimpleString StringFrom(const nullptr_t value)
{
(void) value;
return "(null)";
}
But that fails with the same error:
C:\git\tdd\cpputest\src\CppUTest\SimpleString.cpp:568:31: error: 'nullptr_t' does not name a type
SimpleString StringFrom(const nullptr_t value)
This error doesn't make any sense as I'm including cstddef.
This problem is related with this question.
Any help is appreciated!
The fix is simple enough:
SimpleString StringFrom(const std::nullptr_t value)
{
(void) value;
return "(null)";
}
Thanks for NathanOliver- Reinstate Monica for helping to figure this out.

preprocessor #warning equivalent in Visual C++?

In C# we can use #warning to show a warning in error window.
In Visual C++, #pragma message is something like that, but it just a outputs a message not a warning.
In C++ (Windows, Visual Studio, MSVC) is there a way to show a warning to user purposely?
I tried #warning DEBUG is defined which works in some other compilers, but not MSVC.
It gives me this error:
error C1021: invalid preprocessor command 'warning' AecProject stdafx.h 49
In gcc, #warning works fine in the way that you would expect (i.e. like #error it outputs a message at compile time, but does not cause the compilation to terminate)
It seems that #warning is not available in Visual Studio. Instead you can try experimenting with #pragma warning although this does not emit a message but allows the settings for compiler messages to be altered. The syntax for this is more complex and can be found here
I have a hacky solution that works under some conditions with a C++-14 compiler.
With C++-14 compilers that support [[deprecated("...")]], this (somewhat hacky solution) works for MSVC but also for mingw, g++, and clang:
[[deprecated("read the argument to emit_warning")]]
inline int emit_warning(char const*)
{
return 0;
}
static auto w1 = emit_warning("message1");
static auto w2 = emit_warning("message2");
int main()
{
return 0;
}
It has the advantage over #pragma message in that it actually emits a warning, which means that /WX will convert this warning to an error just like any other, and other MSVC flags can be used to turn it off, though the warning that is emitted is C4996, which is use of a deprecated function.
I played around with putting this in a macro, but the warning gets a lot more complex and hides the real issue, which is this warning message. So, while this is a bit hacky, it at least generates a proper warning.
Output with g++ (Linux):
./test1.cc:6:41: warning: ‘int emit_warning(const char*)’ is deprecated: read the argument to emit_warning [-Wdeprecated-declarations]
6 | static auto w1 = emit_warning("message1");
| ^
./test1.cc:2:12: note: declared here
2 | inline int emit_warning(char const*)
| ^~~~~~~~~~~~
./test1.cc:6:41: warning: ‘int emit_warning(const char*)’ is deprecated: read the argument to emit_warning [-Wdeprecated-declarations]
6 | static auto w1 = emit_warning("message1");
| ^
./test1.cc:2:12: note: declared here
2 | inline int emit_warning(char const*)
| ^~~~~~~~~~~~
./test1.cc:7:41: warning: ‘int emit_warning(const char*)’ is deprecated: read the argument to emit_warning [-Wdeprecated-declarations]
7 | static auto w2 = emit_warning("message2");
| ^
./test1.cc:2:12: note: declared here
2 | inline int emit_warning(char const*)
| ^~~~~~~~~~~~
./test1.cc:7:41: warning: ‘int emit_warning(const char*)’ is deprecated: read the argument to emit_warning [-Wdeprecated-declarations]
7 | static auto w2 = emit_warning("message2");
| ^
./test1.cc:2:12: note: declared here
2 | inline int emit_warning(char const*)
| ^~~~~~~~~~~~
Output with MSVC:
cl -nologo -O2 -Zi -Gy -EHsc -MD -TP -GR -W3 -w14996 -c ./test1.cc -Fo./build/test1.obj
test1.cc
./test1.cc(6): warning C4996: 'emit_warning': read the argument to emit_warning
./test1.cc(7): warning C4996: 'emit_warning': read the argument to emit_warning
Unfortunately
With MSVC, the output doesn't include the actual call, so it's a bit clumsy...I suppose you could create a separate deprecated function for each warning whose name communicates information, but that's even more hacky.
Warning 4996 is a level 3 warning by default, so you need either /W3 or /W14996 to even see the warning.

Compiler does not give error when using list initialization which will cause information loss

In c++ primer(5th), it mentioned:
When used with variables of built-in type, this form of initialization
has one
important property: The compiler will not let us list initialize variables of built-in type if the initializer might lead to the loss
of information:
longdouble ld = 3.1415926536;
int a{ld}, b = {ld}; // error: narrowing conversion required
int c(ld), d = ld; // ok: but value will be truncate
I compile the code using gcc4.8.1 , it only give a warning rather than an error.
g++ -W -Wall -Wextra -pedantic -std=c++0x -o m main.cpp
main.cpp: In function ‘int main()’:
main.cpp:64:13: warning: narrowing conversion of ‘ld’ from ‘long double’ to ‘int’ inside { } [-Wnarrowing]
int a{ld}, b= {ld};
^
main.cpp:64:22: warning: narrowing conversion of ‘ld’ from ‘long double’ to ‘int’ inside { } [-Wnarrowing]
int a{ld}, b= {ld};
Is there any flags that will turn on the feature of the important property ?
A quick search for "gcc diagnostic flag" turns up documentation resources.
Inside your program, you could do this:
#ifdef __GNUC__
# pragma GCC diagnostic error "-Wnarrowing"
#endif
There is a command-line option too: -Werror=narrowing, but since you want to alter the semantic meaning of the program itself according to GCC, putting it in the source code is probably more appropriate.
Note, when it makes a difference other than simple well-formedness, such as in overload selection, GCC does diagnose the condition correctly.
The standard never calls for errors or for warnings: the standard only requires an implementation to issue a diagnostic. Whether such a diagnostic takes the form of a compiler error, or a warning, or something entirely different from them both, is outside the scope of the standard.

Warning on field init order, signed comparison, and unused vars in VC++ & Sun Studio

I am hoping to enable warnings for the following C++ compilation issues and corresponding compilers:
Unused variables -- Sun Studio CC
Example: void m() { int i = 10; }
Signed to unsigned comparison - VC++ and Sun Studio CC
Example: if ((unsigned) 10 < -1);
Wrong field initialization order - VC++ and Sun Studio CC
Example: class A { int i, j; A() : j(0), i(0) {} };
All of these are caught by GCC and I would like to enable these in VC++ and Sun Studio.
bash-4.1$ g++ -Wall main.cpp
main.cpp: In function ‘void m()’:
main.cpp:1: warning: comparison between signed and unsigned integer expressions
main.cpp:1: warning: unused variable ‘i’
main.cpp: In constructor ‘A::A()’:
main.cpp:1: warning: ‘A::j’ will be initialized after
main.cpp:1: warning: ‘int A::i’
main.cpp:1: warning: when initialized here
EDIT: Outside enabling signed to unsigned comparison warnings on VC++, all other options do not seem to be possible.
In Visual Studio, Project Properties, C++, set warning level to 4 (maximum) - VC++ compiler gives all possible warnings. AFAIK, warnings 1 and 2 are reported, and field initialization order is not reported by VC++ compiler.

Compilation error while compiling an existing code base

While building an existing code base on Mac OS using its native build setup I am getting some basic strange error while compilation phase.
Does any of you have any idea, as I have seen it's been discussed earlier as well in this forum without any good reason. I can not see any conflicting files being included.
But still I am unable to compile the code because this error appears.
Source are like the code given below and compilation error appears
$ cat a.h
#include <string>
#include <sstream>
namespace brijesh {
typedef std::string String;
template<class T>
String toString(T value) {
std::ostringstream buffer;
buffer << value;
return buffer.str();
}
$ cat b.h
#include "a.h"
namespace brijesh {
class Platform {
public:
static String getName();
};
}
$ cat b.cpp
#include "b.h"
namespace brijesh {
String Platform::getName()
{
String name = "UNKNOWN";
#ifdef LINUX
name = "linux";
#endif
#ifdef MACOSX
name = "Mac";
#endif
return name;
}
}
flags used for compilation
g++ -c -o test.o -DRELEASE_VERSION -ggdb -arch ppc -mmacosx-version-min=10.4 -pipe -fpermiss ive -nostdinc -nostdinc++ -isystem /Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3 .3 -I/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++ -I/Developer/SDKs/MacOS X10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin -isystem /Developer/SDKs/MacOSX10.3.9. sdk/usr/include -F/Developer/SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks -Wreturn-type -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wno-multichar -Wno-unk nown-pragmas -Wno-long-double -fconstant-cfstrings -MP -MMD x.cpp
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/bits/locale_facets.h: In constructor 'std::collate_byname<_CharT>::collate_byname(const char*, size_t)':
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/bits/locale_facets.h:1072: error: '_M_c_locale_collate' was not declared in this scope
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin/bits/messages_members.h: In constructor 'std::messages_byname<_CharT>::messages_byname(const char*, size_t)':
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin/bits/messages_members.h:79: error: '_M_c_locale_messages' was not declared in this scope
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits: At global scope:
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: 'float __builtin_huge_valf()' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: 'float __builtin_huge_valf()' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: 'float __builtin_nanf(const char*)' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: 'float __builtin_nanf(const char*)' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:900: error: field initializer is not constant
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:915: error: field initializer is not constant
It looks like you're trying to use OS X 10.3 developer tools (Xcode et al) and are trying to target OS X 10.4, which is obviously not going to work. Either change your build command to remove incompatible flags, such as -mmacosx-version-min=10.4, or upgrade to a more current version of OS X + Xcode + SDKs.