gcc

Compiling C code with conflicting types

I'm coding a program that uses ossp-uuid which defines a type called uuid_t. Now, the problem that I have is that this type is already defined in Mac OSX in the file unistd.h. So, the error I get is: /opt/local/include/ossp/uuid.h:94: error: conflicting types for 'uuid_t' /usr/include/unistd.h:133: error: previous declaration of 'uuid_...

What could be causing this crash?

I have a C++ program (GCC) and when I add one or more int members to an abstract base class, the program starts crashing. In the case I've exampled, it seems that by adding this member, a member in a derived class quits getting initialized (or gets stomped on at some point). If I add more members, it starts (not) working different. This ...

Hierarchical ldd(1)

Due to using Gentoo, it often happens that after an update programs are linked against old versions of libraries. Normally, revdep-rebuild helps resolving that, but this time it's a dependency of a python library and python-updater won't pick it up. Is there a "hierarchical" variant of ldd which shows me what shared library depends on w...

How to solve ambiguous function overload due to default constructor in parameter

Let's say I have this class: class Foo { public: void member(std::string s); void member(int64_t &n); }; Now I want to do some thing like int64_t value = 5; Foo f; f.member(value); The problem is that the compiler (at least GCC) gets confused & believes I'm trying to call member with a string using the char* constructor: in...

Static/global constructors on GCC 4.1 / HP-UX 11.23

Quick summary: Lots of existing code that works fine on numerous platforms under gcc 4.1, aCC, VisualAge, and MSVC. I am working on getting this up to snuff on HP-UX currently. The output consists of multiple (8-10) shared libraries. Everything compiles fine now, but when attempting to run any test apps, they immediately segfault in so...

How to redirect the output of gcc compiler to a file?

Redirection operator does not work. So how should we do it? One more question, in makefile, how can we give arguments from command line, like run: a.out ./a.out **<input>** ...

How to prevent a function from being optimized

I am optimizing the entire code, yet I dont want a certain function from being optimized, say for debugging purposes. Is there a way to do it on gcc 3.4+ compiler? ...

stepping into MACRO in VC++

I am debugging a source code that has a lot of big #define'd MACRO routines. I am interesting in stepping into them, but I guess, VC++ does not allow step-in functionality ... so, I am converting them into functions, but this is becoming hard for me Is there a way to step into MACRO routines? especially in VC++? PS: I can port the w...

How can I see parse tree, intermediate code, optimization code and assembly code during COMPILATION ?

I am studying Compilers course, compilation of program follows below steps Lexical analysis Syntax analysis Semantic analysis Intermediate code generation Code optimization Target code generation. How can I see output of each step e.g I want to see parse tree after syntax analysis. I am compiling program on Linux machine with GCC co...

C++ & GCC: How Does GCC's C++ Implementation Handle Division by Zero?

Just out of interest. How does GCC's C++ implementation handle it's standard number types being divided by zero? Also interested in hearing about how other compiler's work in relation to zero division. Feel free to go into detail. This is not purely for entertainment as it semi-relates to a uni assignment. Cheers, Chaz ...

Compiling for amd64 under i386 Debian

Cheers, I want to avoid problems with compiling my code on amd64, yet I don't have a 64-bit CPU available and have no hopes of getting upgrade to my machine any time soon. I have no dreams of testing the code (although that should theoretically be possible using qemu-system) but I'd like to at least compile the code using gcc -m64. Bas...

Enumerated Type Value Not Comparing Correctly

Hello. I'm writing some C code for an embedded application, and I've run into a problem wherein a compare against an enumerated value is not being executed correctly. Take the following code snippet, for example: typedef unsigned int UINT16; typedef enum enum_items_tag { ITEM_1, ITEM_2, ITEM_3, /* ... */ ITEM_918, ...

What's special about gcc flags that start with "tree"?

There are a lot of optimization settings starting with tree. Some are: -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-ter What's special about those flags? ...

Ubuntu: What gcc to use when crosscompiling for the STM32 (Cortex-M3)?

Hi I'm trying to get started with the STM32 (Cortex-M3) and my plan is get this working from Ubuntu (9.04 / AMD64). To start with I got the Olimex stm32-h103 header board and the Olimex ARM-USB-OCD jtag, and on to of that I will probably use OpenOCD, gcc and Eclipse. But right now I'm looking into what version of gcc to use and how ...

C++ Output evaluation order with embedded function calls

Hi, I'm a TA for an intro C++ class. The following question was asked on a test last week: What is the output from the following program: int myFunc(int &x) { int temp = x * x * x; x += 1; return temp; } int main() { int x = 2; cout << myFunc(x) << endl << myFunc(x) << endl << myFunc(x) << endl; } The answer, to me a...

How to create an "empty" space in an executable at a definite address (gcc,linux)?

What I essentially want to do is have another program write data into this "empty space" for the executable to "work" on I thought of appending a signature to the application and then writing the data, searching for it later, but that doesn't quite sound right... Now, other important thing ... I know it should be possible to create...

Visualizing gcc error messages

Hi all do you guys know of any programs which can be used to visualize error messages from gcc. I am imagining something which will allow interactively to collapse all those long template typenames, color code different parts of the error message and what not. ...

DWARF register numbering for Mac on Intel

I'm trying to decode dwarf information for a program and am confused by the dwarf register numbering. According to http://wikis.sun.com/display/SunStudio/Dwarf+Register+Numbering register 4 is the ESP and register 5 is EBP. However the DWARF information I'm decoding (the exception handling unwind information) appears to indicate that ESP...

What are these GCC/G++ parameters?

Hello, everyone. I've been using the UVa Online Judge to solve some programming challenges, and, when submitting my solutions, I'm told the judge will compile my code using the following parameters to GCC/G++ that I don't know: -lm -lcrypt -pipe -DONLINE_JUDGE. What do they do? Thank you very much in advance! ...

When should I use GCC's -pipe option?

The GCC 4.1.2 documentation has this to say about the -pipe option: -pipe Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has no trouble. I assume I'd be able to tell fr...