gcc

What algorithm does gcc use to convert calls through function pointers to direct calls?

I've heard that recent versions of gcc are very good at converting calls through function pointers to direct calls. However, I can't find anything about it on the web or the quick look through gcc's source code. Does anyone know if this is actually true and if so, what algorithm does it use to do this? ...

typeinfo / typeid output

I'm currently trying to debug a piece of simple code and wish to see how a specific variable type changes during the program. I'm using the typeinfo header file so I can utilise typeid.name(). I'm aware that typeid.name() is compiler specific thus the output might not be particularly helpful or standard. I'm using GCC but I cannot find...

gcc error - typedef is initialized (use decltype instead)

I'm compiling some C code, and I get the error typedef 'A' is initialized (use decltype instead) On one of my struct declarations. What could be causing this? ...

Variable initialisation not happening everywhere on certain platforms.

I have a program that I built for RHEL5 32 bit and ubuntu10 64 bit (c++ qt4.6). When I run the program on ubuntu, all the variables are initialized without me needing to code this initialization. But When I run the program on RHEL, some of the variables are not initialized, I have noticed that they are mostly integer type and the typic...

Why does msvc let me do this but not gcc / g++?

In msvc, I have functions like this and it builds but in gcc it doesnt like it. void classname::a(std::string &text) { stdStringFromClass = text; } void classname::b(char *text) { a(std::string(text)); } The issue here is in the &, gcc I think is worried that since I just created that std::string, that passing by reference is...

How are numbers greater than 2^32 handled by a 32 bit machine?

I am trying to understand how calculations involving numbers greater than 232 happen on a 32 bit machine. C code $ cat size.c #include<stdio.h> #include<math.h> int main() { printf ("max unsigned long long = %llu\n", (unsigned long long)(pow(2, 64) - 1)); } $ gcc output $ gcc size.c -o size $ ./size max unsigned long long ...

Labels in GCC inline assembly

In my ongoing experimentation with GCC inline assembly, I've run into a new problem regarding labels and inlined code. Consider the following simple jump: __asm__ ( "jmp out;" "out:;" : : ); This does nothing except jump to the out label. As is, this code compiles fine. But if you place it inside a function, and the...

GCC inline assembly: constraints

I'm having difficulty understanding the role constraints play in GCC inline assembly (x86). I've read the manual, which explains exactly what each constraint does. The problem is that even though I understand what each constraint does, I have very little understanding of why you would use one constraint over another, or what the implic...

Does GCC create typedefs for arrays passed to functions?

While debugging some C code with gdb I came across something I've not seen nor heard of before! The compiler (gcc -O0) seems to have created a new type for passing an array of vectors to a function... I think! Have a look at the code and gdb information below: /* The Vector type - nothing unusual */ typedef struct { float x,y,z; } V...

How to define two depend classes ?

take a look at following simple code : class A; class B { A a; }; class A { B b; }; int main(int argc, char *argv[]) { return 1; } it does not compile, why ? Error Message from GCC (Qt): main.cpp:6: error: field ‘a’ has incomplete type ...

What files are actually included when compiling

Hi, I have a very large code, a lot of which is legacy code. I want to know which of all these files are taking part in the compilation. The code is written in GNU compilers and mostly in C/C++, but some in other programs too. Any advice will be highly appreciated. Thanks, Moshe. I am compiling under linux with a mix of scripts/...

understanding shared libraries using gcc

I am trying to understand the following behavior of shared libraries in C Machine One $ cat one.c #include<stdio.h> int main() { printf ("%d", 45); } $ gcc one.c -o one -O3 $ ldd one linux-gate.so.1 => (0x00331000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00bc2000) /lib/ld-linux.so.2 (0x006dc000) $ cat two.c ...

cygwin1.dll missing when compiling c++ with g++

I'm using cygwin and when I'm compiling hello world with gcc somehow the compiler doesn't understand about using std namespaces (some of them are missing), but when I compile with g++ yes they work. But when I click on the helloworld.exe it says that cygwin1.dll is missing. Is there anything can I do? ...

What's the difference in debug information between gcc with and without "-ggdb1" option?

By default, gcc will add symbol table to the executable, so gdb will get a readable stack trace. Documentation for -ggdb1 option in gcc man page says: Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables...

Anyone know how malloc_info() works?

Hi, I've been trying to figure out how the malloc_info() function located in malloc.h works. I know you have to pass it a FILE* and that no options are implemented yet, but I am at a loss as to what it is actually reporting!? Furthermore i've written a test app that allocates a whole bunch of memory and the values reported from malloc_i...

How can you make a C compiler assume decimal literals (e.g. 1.23) are float and not double?

In my source code, if I write 1.23 as a literal, e.g. doThis(1.23), gcc assumes it's a double. Rather than type doThis((float) 1.23), is there a way to use floats for decimal literals/constants unless otherwise specified in an individual source file? Mega-bonus points, is there a way that works across (nearly) every C compiler? ...

C++ unique_ptr and map

...

most recent release of xcode for leopard, not snow leopard

compiling an app that needs to be compiled with a newer version of the gcc than is available with xcode 3.0 (what is on disk for the leopard install) but the newest download link for 3.2.4 only runs on snow leopard. what is the latest release of xcode that runs on leopard and if you have a link to the dmg that would be awesome. its tort...

how to install llvm-gcc 4.2 on cygwin

hello,i donot know whether cygwin have installed llvm-gcc, if no,i want to know how install llvm-gcc on cygwin in windows.i want to some a lot of detailed steps ,I haven't a clue,my hair is becoming less and less.thank you ...

gcc preprocessor

is there a option that gcc preprocessor could generate C source code and filt out un-relavented source code. for example. a c file has #define switch to define for many diffenrent platforms. I'm only intersted in one platform, I want c preprocessor to filt out un-related code. Could GCC support this? Thanks for help Richard Luo ...