gcc

gcc compile error: cast specifies array type

The following code is perfect valid, int *ia = (int[]){1,3,5,7}; but when I compile the next line of code, char *p = (char[]) "abc"; gcc says test.c:87: error: cast specifies array type It seems they are casted in the same way. Why did the second one get an err msg? As you guys said, "abc" is a pointer, which cannot be conver...

change visibility of symbols in shared library files

Hi all, I tried to compile sigintr.c in DD-WRT/src/router/rflow with arm-linux-gcc. The problem I encountered is: sigintr.o: In function siginterrupt': sigintr.c:(.text+0x88): undefined reference to_sigintr' collect2: ld returned 1 exit status make[1]: * [rflow] Error 1 I can find '_sigintr' in libc.so, but unfortunately...

Linux static linking is dead?

In fact, -static gcc flag on Linux doesn't work now. Let me cite from the GNU libc FAQ: 2.22. Even statically linked programs need some shared libraries which is not acceptable for me. What can I do? {AJ} NSS (for details just type `info libc "Name Service Switch"') won't work properly without shared libraries. NSS al...

How can I get more accurate results from gcov?

I'm experimenting with gcov using mingw gcc 4.4.0. I've been getting some interesting but strange results. A common pattern is something like this... 5162: 66: std::string::iterator i = l_Temp.begin (); 5162: 67: std::string::iterator j = l_Temp.end () - 1; -: 68: char ch; -: 69: 20564: 70: wh...

GCC with the -fomit-frame-pointer option

I'm using GCC with the -fomit-frame-pointer and -O2 options. When I looked through the assembly code it generated, push %ebp movl %esp, %ebp at the start and pop %ebp at the end is removed. But some redundant subl/addl instructions to esp is left in - subl $12, %esp at the start and addl $12, %esp at the end. How will I be able to re...

Porting NewLib for my OS: some questions

Hello, I am trying to port NewLib for my OS (I am following this tutorial: http://wiki.osdev.org/Porting_Newlib), and I have some questions. Once LibGloss is done and compiled, when exactly I'll have to use the libnosys.a that have been created? Is it when I will compile my main.c? > mipsel-uknown-elf-gcc main.c -Llibnosys.a M...

Getting the name of the calling function in C (without using the preprocessor).

Hello, I was wondering if there is a way of finding which function called the current function (at runtime) in C. I know you could use __FUNCTION__ in gcc, but is there a way without using the C preprocessor? Probably not. Cheers ...

C extension: <? and >? operators

I observed that there was at some point a <? and >? operator in GCC. How can I use these under GCC 4.5? Have they been removed, and if so, when? Offset block_count = (cpfs->geo.block_size - block_offset) <? count; cpfs.c:473: error: expected expression before ‘?’ token ...

GCC Inline-assembly: call dword ptr

Hello. If I have the following code in Windows VC++: DWORD somevar = 0x12345678; _asm call dword ptr [somevar] How can I make the same thing in GCC inline-assembly, with AT&T syntax? __asm__ __volatile__ ( "call dword ptr [%%edx]" : : "d" (somevar) ); I've tried something like this, but it generates an "junk" error... And ...

How can I compile a standalone FFTW library?

I need to compile a standalone .a or .so library in Ubuntu 10.04 from the FFTW source code. I find that the directory layout of the source distribution is so complex that I have no idea where to start. I need to use an older version of gcc as well. ...

gcc doesn't warn about calling a nullary function WITH parameters?

Can anyone tell me, why in the blazes GCC (e.g. 4.4.3) does not warn about or error the incorrect call of a nullary function? void hello() { } int main( int argc, char* argv[] ) { int test = 1234; hello(test); return 0; } (see also http://bytes.com/topic/c/answers/893146-gcc-doesnt-warn-about-calling-nullary-function-parameters) ...

Compiling with GCC on windows 7: \mingw32\bin\ld.exe: cannot open output file a.exe

This is what I get when trying to compile a simple hello world program with gcc. c:\>gcc hello.c hello.c:9:2: warning: no newline at end of file C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot open output file a.exe : Permission denied collect2: ld returned 1 exit status Does it have something to do with w...

Objective-C compiler flags

When compiling Objective-C from the command line (gcc), what are some good flags to use? Many of the standard C flags (-Wall, -ansi, etc) don't play well with Objective-C. I currently just use -lobjc and -frameworkwith various frameworks. ...

How are structs laid out in memory in C++?

Is the way C++ structs are laid out set by the standard, or at least common across compilers? I have a struct where one of its members needs to be aligned on 16 byte boundaries, and this would be easier if I can guarantee the ordering of the fields. Also, for non-virtual classes, is the address of the first element also likely to be th...

C++ current function name as string

Hello, Is there any way to get current function name in C++? I want to track some functions calls order. Is there something like __FILE__ or __LINE__? Thank you! ...

old gcc version for boost

When I try to use boost on an old Linux system, I get the message: Compiler not configured - please reconfigure The version of my gcc is: gcc version 2.9-gnupro-99r1 And in boost's gcc.hpp file I see: // versions check: // we don't know gcc prior to version 2.90: #if (__GNUC__ == 2) && (__GNUC_MINOR__ < 90) # error "Compile...

cross gcc crti.o

I have followed the instructions at Cross linux from scratch for powerpc, but I can't get past the gcc-final stage due to an ld error crti.o: no such file or directory. My tool chain is separated into two directories: /opt/builder/tools and /opt/builder/cross-tools, with Linux headers and eglibc in the first and cross-utilities in the ...

object file from .a not included in .so

Hi, I have created a .c file which is being converted to a .o file along with around 300 other .c files and included in a .a static library. This library, along with many others is being used to create a .so dynamic library. On analyzing both the .a and the .so file with nm, I found that for some reason the symbols defined in the .c fil...

Compiling C++/GTK within Eclipse

I'm fiddling around with the C/C++ version of Eclipse to build a simple GTK app. However, I can't seem to be able to compile a GTK sample from within Eclipse. I think gtk is installed properly, used the ubuntu Package manager. the code is: #include <gtk-2.0/gtk/gtk.h> int main( int argc, char *argv[] ) { GtkWidget *window; g...

Trying compile a C Code with PHP

I have a file named gcc.exe and I have a php page... I want to use: gcc test.c And, if there's some compilation error, I want to show it on the php page... But I can't. What happens is: If the file is correct, it generates the .exe file, but if it's wrong, nothing happens. What I want here, again, is to show all errors. Anyone has an...