gcc

built grep slower than grep that comes with Linux

I am trying to understand why grep built by me is much slower than the one that comes with the system and trying to find what compiler options are used by grep that comes with the system. OS Version: CentOS release 5.3 (Final) grep on system: Version: grep (GNU grep) 2.5.1 Size: 88896 bytes ldd output: libpcre.so.0 => /lib64/...

at&t asm inline c++ problem

My Code const int howmany = 5046; char buffer[howmany]; asm("lea buffer,%esi"); //Get the address of buffer asm("mov howmany,%ebx"); //Set the loop number asm("buf_loop:"); //Lable for beginning of loop asm("movb (%esi),%al"); //Copy buffer[x] to al asm("inc %e...

strange SDL memory usage depending on bits per pixel

I have a very simple SDL program that uses only 1MB of memory with 32 bits per pixel, 2.4MB with 24 bits per pixel, 1.9MB with 16 bits per pixel, and 1.4MB with 8 bits per pixel. what is with this strange memory usage? why does the most bits per pixel take up the least amount of memory? C++ GCC thanks ...

Can you convert this inline asm into non-inline one?

Hi, I came across this inline asm. I am not sure how it should look without this syntax... Could someone show it to me? __asm__ volatile ("lock\n\tincl %0" :"=m"(llvm_cbe_tmp__29) :"m"(*(llvm_cbe_tmp__29))"cc"); ...

Does the restrict keyword provide significant anti-aliasing benefits in gcc / g++

Has anyone seen any numbers / analysis on whether or not use of the C / C++ restrict keyword in gcc / g++ actual provides any significant performance boost in reality ( and not just in theory )? I've read various articles recommending / disparaging it's use, but I haven't ran across any real numbers practically demonstrating either side...

Questions on GCC linker

Apologize because for the moment I don't have the environment to experiment and sort out the following questions myself: 1) Let's say I have four library files: libmylib_super.a and libmylib_super.so, mylib_dumb.a and mylib_dumb.so. While specifying libraries to link to, what are the differences between the following approaches: A) -l:...

Control GNU autotools make output

I am using GNU autoconf/automake. Is there any way I can control what make prints to stdout from configure.ac or Makefile.am? For example, suppress mv and cp commands being printed out to the screen, only print the name of the file being compiled by gcc rather than the whole command line, highlight gcc warnings in some way. ...

how to undefine a define at commandline using gcc

How do I at compiletime undefine a compiler macro using gcc. I tried some compile args to gcc like -D but I cant get to see the "not defined" message. Thanks #include <iostream> #define MYDEF int main(){ #ifdef MYDEF std::cout<<"defined\n"; #else std::cout<<"not defined\n"; #endif } ...

A way to do c++ "typedef struct foo foo;" for c

Going by gcc version 4.4.2, it appears that saying typedef struct foo foo; // more code here - like function declarations taking/returning foo* // then, in its own source file: typedef struct foo { int bar; } foo; is legal in C++ but not in C. Of course I have a body of code that compiles fine in C++ by using the foo type but it ...

a gcc sqrt function bug?

The following program cannot compile in gcc. But it compiles OK with g++ and MSC++ with .c extension. #include <math.h> #include <stdio.h> int main() { double t = 10; double t2 = 200; printf("%lf\n", sqrt(t*t2)); return 0; } My system is CentOS, the version info. > gcc --version gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)...

Is Loop Hoisting still a valid manual optimization for C code?

Using the latest gcc compiler, do I still have to think about these types of manual loop optimizations, or will the compiler take care of them for me well enough? ...

Using bts assembly instruction with gcc compiler

I want to use the bts and bt x86 assembly instructions to speed up bit operations in my C++ code on the Mac. On Windows, the _bittestandset and _bittest intrinsics work well, and provide significant performance gains. On the Mac, the gcc compiler doesn't seem to support those, so I'm trying to do it directly in assembler instead. Here's...

What do I need to do to link with xlib?

I am using GCC, what switches do I need to add to link with Xlib? After searching, all I could find was -lX11, but that gave me ld: library not found for -lX11 I am using a mac (10.6), but I would not like anything that is Mac specific. ...

Why is it important for C / C++ Code to be compilable on different compilers?

I'm interested in different aspects of portability (as you can see when browsing my other questions), so I read a lot about it. Quite often, I read/hear that Code should be written in a way that makes it compilable on different compilers. Without any real life experience with gcc / g++, it seems to me that it supports every major platf...

Does GCC have a GUI?

Does GCC have a GUI or Graphical IDE? Edit: I'm on Windows Vista /7 OR Ubuntu 9.10. I'm looking for something beginner-friendly. I've used Flash CS3 for 2 years and been doing HTML for 6. I have toyed briefly with Java and once or twice tried C++. I prefer working on Windows for now. ...

How do I sort the symbols of other sections besides the "COMMON" section?

The gnu linker "ld" supplies the option "-sort-common" which sorts the uninitialized global parameters, known as the COMMON section symbols, by their size. When the linker aligns the symbols to even addresses, this option helps minimizing the holes in the section. For example, if we define: --main.c char a; short b; ch...

debug via going into preprocessing, compilation, assembly and linking

Hi, Sometimes when there are errors output by gcc, one will break down the the process for each stage of preprocessing, compilation, assembly, linking by options like -E, -S and -c. Here is an example. I just wonder what types of errors could happen at each of these four stages and if there is one error occuring at one of these stages ...

g++, colorgcc and ccache

Trying to combine ccache and colorgcc. Following link text: my g++ is soft link to colorgcc ~/.colorgccrc contains line: "g++: ccache /usr/bin/g++" When running g++ --version receive: Can't exec "ccache /usr/bin/gcc": No such file or directory at /usr/lib/perl5/5.8.8/IPC/Open3.pm line 246. open3: exec of ccache /usr/bin/gcc --ver...

Is there a Linux equivalent of Windows' "resource files"?

I have a C library, which I build as a shared object for Linux and a DLL for Windows with MinGW32. The API depends on a couple of data files (statistical models) which I'd really like to roll in with the SO/DLL so that deployment is just one file. It looks like I can achieve this for Windows with a "resource file" compiled with windres,...

c gcc compiler options for pointer arithmetic warning

I m using the following flags , but still I m not able to get this warning: "pointer of type 'void *' used in arithmetic" Flags used: -O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-compare -Wno-pointer-sign -Wno-attribut...