gcc

GCC __attribute__((aligned(x)) explanation

Hi, i have the following code: #include <stdio.h> int main(void) { float a[4] __attribute__((aligned(0x1000))) = {1.0, 2.0, 3.0, 4.0}; printf("%p %p %p %p\n", &a[0], &a[1], &a[2], &a[3]); } And i have the following output: 0x7fffbfcd2da0 0x7fffbfcd2da4 0x7fffbfcd2da8 0x7fffbfcd2dac Why the address of a[0] is not a...

LSB AppChecker: GCC links against unused libraries

I'm checking the portability of a shared object (.so) with the LSB AppChecker. One of the problems it reports is that there is one external library (libm.so.6) that is not being used but is linked against anyways. How can I prevent GCC from linking to this unneeded library? EDIT: The output of the ldd command against my shared object i...

Is there a way to automatically make a library either static or dynamic?

I know this might be a long shot, but here it goes. I have several active projects and each has sub project library which gets compiled when the main project compiles. These libraries are dynamic ones, but recently there was an issue that might arise a need for those libraries (most of them are shared between projects) to be static inste...

Multiple glibc libraries on a single host

Multiple glibc libraries on a single host My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't work on this version and requires glibc-2.3.3. Is it possible to have multiple glibcs installed on the same host? This is the error I get when I run my program on the old glibc: ./myapp: /lib/i686/libc.so...

Compile a DLL in C/C++, then call it from another program

I want to make a simple, simple DLL which exports one or two functions, then try to call it from another program... Everywhere I've looked so far, is for complicated matters, different ways of linking things together, weird problems that I haven't even begun to realize exist yet... I just want to get started, by doing something like so: ...

Can gcc accurately catch useless conditionals?

Please examine the following code: if (foo->bar == NULL); foo->bar = strdup("Unknown"); I spent the last part of three hours hunting down that leak with Valgrind, feeling very silly when I discovered the bogus ';'. I know that the above code is valid C, however I would love for gcc to be able to tell me if I'm using a conditional ...

default template class argument confuses g++?

Hi all, Yesterday I ran into a g++ (3.4.6) compiler problem for code that I have been compiling without a problem using the Intel (9.0) compiler. Here's a code snippet that shows what happened: template<typename A, typename B> class Foo { }; struct Bar { void method ( Foo<int,int> const& stuff = Foo<int,int>() ); }; The g++ compi...

How do I get Eclipse to find and use a gcc based toolchain in a non-standard location

Hi, I am trying to get Eclipse to work with a GCC based ARM cross compiler. How can I configure eclipse to add the new tool chain to its list of tool chains? The tool chain is a Raisonance distributed GCC tool chain: C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe ...

OS X gcc "installation problem"

OS X 10.5.6, Xcode 3.1 with iPhone support. After compiling some apps for iPhone device in Xcode, I've noticed that calling GCC from command line no longer works: $ gcc gcc-4.0: installation problem, cannot exec '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin//i686-apple-darwin9-gcc-4.0.1': No such file or directory Note ho...

intrinsic memcmp

According to the gcc docs, memcmp is not an intrinsic function of GCC. If you wanted to speed up glibc's memcmp under gcc, you would need to use the lower level intrinsics defined in the docs. However, when searching around the internet, it seems that many people have the impression that memcmp is a builtin function. Is it for some compi...

C enum different compilers

I'm building an application that needs to compile on both Windows and Linux. The application is written in C, almost everything works except the MinGW compiler refuses this typedef struct somestruct{ ...snip... enum {NODE, REAL} type; }; somestruct* something; switch (something->type){ case NODE: ...stuff...; break; case ...

[c#, c++] Why does a compiler dislike implicitly casting to uint's?

I have run into a couple of similar quirks regarding uint usage in both C++ and C#, and now I'm wondering on the reasoning (which may be completely different for each example). For both of these examples, note that I am compiling with the warning levels set to maximum. (1) gcc complains about comparing an int to a uint in the following...

Unit testing with -fno-access-control

I have seen many crazy methods to get access to private variables when unit testing. The most mind blowing I've seen is #define private public. However, I've never seen anyone suggest turning off private variables at the compiler level. I had always just assumed that you couldn't. I've complained to many a developer that unit testing...

How do I create const arrays and calculated const values in C++ class?

I'm running into some compiler errors I don't understand. I'm pretty sure I'm doing something very wrong here but I don't know what. I would like all the world constants to be defined as belonging to the class. Notes: I'm only using classes as structs with attached members. I'm not following strict Object-Orriented Design on purpose....

GCC is not linking library to a non-default path!

I have boost C++ libraries already installed on my Fedora10 machine but I want to use a newer version that I keep at some location in my home folder. I want g++ to use include and library files from my home folder location instead of default (/usr/include and /usr/lib64). For that matter, I also have declared CPLUS_INCLUDE_PATH and LIBR...

gcc: Enabling debug symbols in shared library

I am creating a shared library using gcc and suspect that there may be some memory leaks from the shared library. To debug, I need to enable debug symbols when creating the shared library. To build, I am using gcc -g ... [-g is for enabling debug information] But the library [.so file] size is not changing for both -g, and without -g. B...

Precompiled headers supported on gcc 3.3.3 ?

Are precompiled headers supported on gcc 3.3.3 ? If yes what is the syntax to generate and use precompiled headers on Linux with gcc 3.3.3. We crosscompile our projects on Windows and Linux, on Windows we precompile stdafx.h and I'm investigating how to set it up so that it is precompiled on Linux as well. I'm aware of the gcc doc , I'...

How to generate gcc debug symbol outside the build target?

I know I can generate debug symbol using -g option. However the symbol is embeded in the target file. Could gcc generate debug symbol outside the result executable/library? Like .pdb file of windows VC++ compiler did. ...

Selecting message language in gcc and g++

I feel dumb asking this, but here it goes. I use gcc/g++ on Linux and since my install is in spanish (my native language), gcc prints warnings and errors in spanish. I rather read them in english for two reasons: English messages are far easier to google. Spanish translations are more or less horrible. Any help? I've googled for this...

GCC build problem (#include_next limits.h)

When i try to $ make depend -f gcc.mak a middleware on my Ubuntu machine I get this /usr/include/../include/limits.h:125:26: error: no include path in which to search for limits.h This is the contents around limits.h:125: /* Get the compiler's limits.h, which defines almost all the ISO constants. We put this #include_next outs...