gcc

gcc compile time notes/msg

I know MSVC can do this via a pragma message -> http://support.microsoft.com/kb/155196 Does gcc have a way to print user created warnings or messages? (I couldn't find a solution with google :( ) ...

user warnings on msvc AND gcc?

In MSVC I have this in a header: #define STR(x) #x #define STR2(x) STR(x) #define NOTE(text) message (__FILE__ "(" STR2(__LINE__) ") : -NOTE- " #text) #define noteMacro(text) message (__FILE__ "(" STR2(__LINE__) ") : " STR2(text)) and I do #pragma NOTE(my warning here) GCC has: #warning(my warning here) How...

Make one gcc warning an error?

I get this warning from GCC: warning: cannot pass objects of non-POD type 'class Something' through '...'; call will abort at runtime It's pretty deadly, especially since it calls an abort. Why isn't this an error? I would like to make it an error, but: How do I make a specific warning an error? Which warning is it? According to ...

gcc, change some warnings into errors

I have a thread but unfortunately none of the suggestions are working for me http://stackoverflow.com/questions/475407/make-one-gcc-warning-an-error in my makefile i specify -Werror=uninitialized, no errors occur. I changed it to -Wuninitialized and i see my warning, -Wno-uninitialized makes it go away as expected, but why isnt -Werror...

Why does STL map core dump on find?

So, I have this situation where I need to see if an object is in my stl map. If it isn't, I am going to add it. char symbolName[] = { 'H', 'e', 'l', 'l', 'o', '\0' }; map<string,TheObject> theMap; if (theMap.find(symbolName)==theMap.end()) { TheObject theObject(symbolName); theMap.insert(pair<string, TheObject>(symbolName, ...

How does template argument shadowing work in VS2005?

In GCC this code won't compile, because T gets shadowed, however in VS2005 it compiles with no warnings, so what are the assumptions VS compiler is making? template<typename T> class Foo { template<typename T> void Bar(const T& bar) { ... } }; ...

Is there a correct way to avoid warnings when comparing two different enums?

When comparing enums that come from different sources such as those of the following code GCC emits warnings. Is there a way to avoid these warnings without c-style casts? struct Enumerator { enum { VALUE = 5 }; }; template<int V> struct TemplatedEnumerator { enum { VALUE = V }; }; if(Enumerator::VALUE == TemplatedEnumerator<5...

xcode / gcc linking problem: file is not of required architecture

Hi, I am trying to port a windows project that includes boost 1.37 and wxwidgets to the mac. It compiles ok, but the linker gives me a "file is not of required architecture for architecture ppc" error for libz.1.dylib and the same message as a warning a few other libraries. I also get a "duplicate dylib" warning for libz.1.dylib. The ...

How to supress specific warnings in g++

I want to suppress specific warnings from g++. I'm aware of the -Wno-XXX flag, but I'm looking for something more specific. I want some of the warnings in -Weffc++, but not all of them. Something like what you can do with lint - disable specific messages. Is there a built in way in gcc to do this? Do I have to write a wrapper script? ...

gfortran: how to control output directory for .mod files

Is there is a way to put .mod files, generated by gfortran (GCC), into a separate output directory? I know how to place object files or other output with the -o flag as in: gfortran -c test.f03 -o /path/to/output/dir/test.o But the .mod files (which are generated by the above call) are not affected by the -o flag and placed in the curr...

How do I check if gcc is performing tail-recursion optimization?

How do I tell if gcc (more specifically, g++) is optimizing tail recursion in a particular function? (Because it's come up a few times: I don't want to test if gcc can optimize tail recursion in general. I want to know if it optimizes my tail recursive function.) If your answer is "look at the generated assembler", I'd like to know ex...

Including boost::filesystem produces linking errors

Ok first off, I am linking to boost_system and boost_filesystem. My compiler is a custom build of MinGW with GCC 4.3.2 So when I include: #include "boost/filesystem.hpp" I get linking errors such as: ..\..\libraries\boost\libs\libboost_system.a(error_code.o):error_code.cpp: (.text+0xe35)||undefined reference to `_Unwind_Resume'...

How to start writing a PHP5 extension in C++

I'm writing a PHP5 extension, and while I could write it in C, it would be easier to use C++ and take advantage of the STL and Boost. Trouble is, the tutorials I've seen only deal with C, and I'm looking for a basic example which uses C++ Here's what I've tried so far: config.m4 [ --enable-hello Enable Hello World support]) if tes...

What do these Makefile constructs mean?

Can someone help me figure out the following make file? BINS=file1 file2 file3 all: $(BINS) clean: rm -f $(BINS) *~ $*: [email protected] gcc -g -o $@ $? Here are my questions: What is the -g option of gcc? What are $* and $@ How does it know to execute the last target? Thanks! ...

Linking symbols to fixed addresses on Linux

How would one go about linking (some) symbols to specific fixed addresses using GNU ld so that the binary could still be executed as normal in Linux (x86)? There will not be any accesses to those symbols, but their addresses are important. For example, I'd have the following structure: struct FooBar { Register32 field_1; Regist...

Why does the g++ 4.0 version of map<T>::erase(map::<T> iterator) not return a iterator?

Hi, I'm porting a medium-sized C++ project from Visual Studio 2005 to MacOS, XCode / GCC 4.0. One of the differences I have just stumbled across has to do with erasing an element from a map. In Visual Studio I could erase an element specified by an iterator and assign the return value to the iterator to get the position of the next ele...

create a my_printf that sends data to both a sprintf and the normal printf?

Hi I am playing with the printf and the idea to write a my_printf(...) that calls the normal printf and a sprintf that sends the result to a special function. (I was thinking about sprintf since that behaves just like printf on most platforms). My idea was to write a small macro that did this: #define my_printf(X, Y...) do{ printf...

Why are there extra instructions in my gcc output?

GCC compiles (using gcc --omit-frame-pointer -s): int the_answer() { return 42; } into .Text .globl _the_answer _the_answer: subl $12, %esp movl $42, %eax addl $12, %esp ret .subsections_via_symbols What is the '$12' constant doing here, and what is the '%esp' register?...

[gcc generated assembly] .comm?

I just translated this program, #include <stdio.h> int dam[1000][1000]; int main (int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); return 0; } to assembly using gcc producing, .cstring LC0: .ascii "Hello, World!\0" .text .globl _main _main: pushl %ebp movl %esp, %eb...

Line number of segmentation fault

Is there any gcc option I can set that will give me the line number of the segmentation fault? I know I can : Debug line by line Put printfs in the code to narrow down. Thanks! Edits: bt / where on gdb give No stack. Helpful suggestion ...