gcc

Defining global array

I have the following static array in header file: static MyStruct_t MyStructArray[] = { ...... ...... ...... } But gcc issues a warning: warning: `MyStructArray' defined but not used What is the correct way to handle the situation? UPD: Defining the array as const: const MyStruct_t MyStructArray[] = { .........

Why assignment of double to int does not trigger gcc warnings?

int i = 3.1 / 2 does not cause any warnings,even with -Wall option.Sometimes,I would like to know where precision lose.Why gcc does not support this warning,while msvc support this one? thanks. EDIT: my gcc -v shows Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,o...

How to install mingw manually?

Once I saw gcc version 4 at sf.net host page of mingw,I managed to download the whole package and install the new package,but it turns out a lot of mistakes(create process errorwhile run gcc and give out non-meaningful code) and Now I have to rollback to the orginal automatical installed version. My question is: is there anyone have suc...

Inherit interfaces which share a method name

There are two base classes have same function name. I want to inherit both of them, and over ride each method differently. How can I do that with separate declaration and definition (instead of defining in the class definition)? #include <cstdio> class Interface1{ public: virtual void Name() = 0; }; class Interface2 { public: ...

Is make -j distcc possible to scale over 5 times?

Since distcc cannot keep states and just possible to send jobs and headers and let those servers to use only the data just sent and preprocess and compile, I think the lastest distcc has problem in scalability. In my local build environment which has appx. 10,000 c/c++ files to build, I could only make 2 times faster than not using distc...

Is there a GCC pragma to override generation of debug info (-g) for some section of code?

I'd like to include some debug information in an application, but hide certain symbols from appearing. Is there any way to do this with GCC 4.0 (or 4.2)? This is on OSX. ...

Can I link unresolved reference to abort?

I'm trying to write some small tests for a fairly small part of a fairly large project. Attempting to link this beast is unfortunately fairly impossible without linking the entire project together, which I don't want to do (it's a pretty complex system for finding all the dependencies and stuff, and I perfer not to meddle with it). Now,...

ccache and absolute path

I use cmake to create a makefiles. cmake creates gcc line containing absolute pathes. To speed up compilation I use ccache. Building same code from different locations (e.g. several developers compile the same code, each under its home directory) causes ccache cach miss. Googled it, but not found a good answer. ...

gcc not generating debug files

Hi. I want to compile an application with debug information using gcc and gdb. When I do the following, the debug (.dSYM) files are generated correctly: gcc -ggdb src/test.c -o build/test If I, however, split this into a compile step and a link step, like this: gcc -ggdb -c src/test.c -o build/test.o gcc -ggdb build/test.o -o dist/b...

Bugs related to template-functions in GCC 3.4.6

I ran into a strange compile error at the office today and I'm suspecting it to be a bug in our version of GCC (3.4.6). I've been able to boil it down to a few lines of code (below). The compile error I get is: test.cpp:26: error: expected primary-expression before '>' token test.cpp:26: error: expected primary-expression before ')' tok...

How do I get gcc-3.2.2 on RHEL 5?

Hi, We just had our hosting provider build out a new RHEL 5 box for us to test some legacy stuff on: uname -a: Linux myserver.foo.com 2.6.18-164.9.1.el5 #1 SMP Wed Dec 9 03:29:54 EST 2009 i686 i686 i386 GNU/Linux cat /etc/redhat-release: Red Hat Enterprise Linux Server release 5.4 (Tikanga) gcc -v: gcc version 4.1.2 20080704 (Red Hat...

Will GCC inline a function that takes a pointer?

I have a function which operates on piece of data (let's say, an int), and I want to change it in place by passing a reference to the valule. As such, I have the function: void myFunction(int *thing) { ... }. When I use it I call it thus: myFunction(&anInt). As my function is called frequently (but from many different places) I am conc...

Xcode - Setting Other C Flags on dependent projects

I have an Xcode project (for an iPhone application) that uses cocos2d. I have cocos2d set up as a dependent project, so it builds alongside my project. Now I need to set a compiler flag to Cocos, and I can't find where to do it. I tried setting the compiler flag in my build settings, but it doesn't propagate to the dependent projects. ...

gcc version 4.1.2 in mac os x

I am taking a programming class and we are required to use the gcc 4.1.2 compiler to compile our c++ projects. I will be creating my projects in xcode and can't find how to set that compiler. I went to the get info window on the project and hit the drop down under Compiler Version, however I do not have 4.1.2 on the list. It seems that t...

unpredictable behavior of Inline functions with different definitions

I have the following source files: //test1.cpp #include <iostream> using namespace std; inline void foo() { cout << "test1's foo" << endl; } void bar(); int main(int argc, char *argv[]) { foo(); bar(); } and //test2.cpp #include <iostream> using namespace std; inline void foo() { cout << "test2's foo" << endl; } void ...

GCC, ARMboot - Creating standalone application without any library and any OS

I have an embedded hardware system which contains a bootloader based on ARMboot (which is very similar to Uboot and PPCboot). This bootloader normally serves to load uClinux image from the flash. However, now I am trying to use this bootloader to run a standalone helloworld application, which does not require any linked library. Actuall...

Why C is the language of compilers- when a Scheme subset would seem to be a better fit?

I was just listening to episode 57 of Software Engineering Radio (TRANSCRIPT: http://www.se-radio.net/transcript-57-compiletime-metaprogramming ) I'm only 40 minutes in, but I'm wondering why C is the language of compilers- when a Scheme subset would seem to be a better fit? (or some other HLL) (excluding the obvious reason of not wanti...

Why do applications compiled by GCC always contain the _mcount symbol?

Libraries don't always contain the _mcount symbol, but applications do (you can verify this with gobjdump or the nm utility). I've read that _mcount is used to implement profiling, but the symbol is present even when profiling is disabled and optimization is enabled (-O2). Does it serve some other additional purpose? Update: I am on Sol...

Troubleshooting compile time link errors

I'm trying to statically link to libcrypto.a (from the openssl library) after building it from source with a new toolchain. However whenever I try to use any of the functions from that library, I keep receiving "undefined reference" errors. I've made sure the right header file was included. I've also double checked the symbol table of li...

Why does the C++ linker require the library files during a build, even though I am dynamically linking?

I have a C++ executable and I'm dynamically linking against several libraries (Boost, Xerces-c and custom libs). I understand why I would require the .lib/.a files if I choose to statically link against these libraries (relevant SO question here). However, why do I need to provide the corresponding .lib/.so library files when linking m...