gcc

How to optimize the layers of pointer indirection

I am trying to optimize this sort of things in a heavy computing application: say I have a double d[500][500][500][500]; and the following is quite costly at least from compiler perspective double d[x][y][j][k] I want to tell compiler is that it's contiguous memory, to facilitate computing the offset. In my example, I have s...

Why I couldnt work with the gcc compiler without '\n' in printf?

I have written a printf() statement like below: printf("hello\n"); this works fine when built using Linux' gcc compiler. However if I write printf("hello"); the print doesn't appear on the screen. There is some buffering mechanism it seems? Can anybody give me more information on this? ...

How portable is weak linking? #pragma weak my_symbol

Hi, How portable is weak linking? #pragma weak my_symbol I see that question: ow-to-make-weak-linking-work-with-gcc discusses how to get it working. But is there a good way to do this such that gcc is not required? What is the difference between weak linking and guarding the declartion with an #ifdef? #ifndef my_weak_fn void my_w...

How do I tell if a C integer variable is signed?

As an exercise, I'd like to write a macro which tells me if an integer variable is signed. This is what I have so far and I get the results I expect if I try this on a char variable with gcc -fsigned-char or -funsigned-char. #define ISVARSIGNED(V) (V = -1, (V < 0) ? 1 : 0) Is this portable? Is there a way to do this without destro...

What is "strip" (GCC application) used for?

Hi, what is this little application for? When using it without any options reduces the size of the executables, but how/what it does? ...

Problem with GCC allocated memory on VPS

Hey all, I am trying to install a python module on my VPS and am running into the following problem once I try to run the install: virtual memory exhausted: Cannot allocate memory error: command 'gcc' failed with exit status 1 I tried a few things that I read online to try to solve this but have yet to have any luck. I spoke with a ...

Using GCC's C++0x mode in production?

Is anyone using the GCC 4.4.0 C++0x support in production? I'm thinking about using it with the latest MinGW, but I'm not sure if it's mature enough. I'm interested in: TR1 support auto initializer lists ...

Cygwin gcc - asm error:

I have a project written in C that originally was being done on Linux, but now must be done on Windows. Part of the code include this line in several places asm("movl temp, %esp"); But that causes an "undefined reference to `temp'" error. This has no problem compiling on Linux using the gcc 4.3.2 compiler (tested on another machine)...

C++ Debug builds broke in Snow Leopard X-Code

After upgrading to XCode 3.2 and Snow Leopard, my debug builds are broken and fail at runtime. Stringstreams do not seem to work. They work in Release mode. I've narrowed it down to a combination of GCC 4.2, OSX SDK 10.6 and the _GLIBCXX_DEBUG pre-processor symbol. These are the defaults for new XCode projects' Debug configurations. ...

Casting pointer as template argument: Comeau & MSVC compile, GCC fails

Consider the following code: template<int* a> class base {}; int main() { base<(int*)0> test; return 0; } Both Comeau and MSVC compile this without issues (except for Comeau warning about an unused variable), while GCC fails on the base<(int*)0> test; line, stating In function `int main()': a casts to a type other than...

std::string::assign() causes segfault

The situation: I have a std::vector that contains strings at specific offsets. Here's a shortened dump: ... @128 00 00 00 00 00 00 00 00 73 6F 6D 65 74 68 69 33 ........somethin @144 38 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ng.............. @160 00 00 00 00 00 00 00 00 31 2E 32 2E 33 00 00 00 ........1.2.3... @176 00...

Compiling JVMTI agent (using GCC, on OSX Snow Leopard)

I am trying to build a JVMTI agent using the g++ command on Snow Leopard and I get the following error: $ g++ -o agent.so -I `/usr/libexec/java_home`/include agent.cpp Undefined symbols: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found collect2: ld returned 1 exit status I am a total novice when it comes to gcc...

Weird behaviour of Koenig Lookup

Hi, consider the following program: namespace NS2 { class base { }; template<typename T> int size(T& t) { std::cout << "size NS2 called!" << std::endl; return sizeof(t); } }; namespace NS1 { class X : NS2::base { }; } namespace NS3 { template<typename T> i...

Is there a rebase (dll) command in linux/gcc?

On Windows, rebase changes the preferred load location for a dll and (I've read) can dramatically decrease application load time. Is there a similar concept on Linux and/or gcc? ...

fileno, F_LOCK and F_ULOCK become undeclared and unavailable when I add std=c99 flag to gcc

I have these headers in a c code #include <stdio.h> #include <unistd.h> Everything compiled fine until I added -std=c99 flag to gcc command (to enable restrict). And this triggered the following errors. warning: implicit declaration of function fileno error: F_LOCK undeclared (first use in this function) error: (Each u...

Using GCC through Xcode to compile basic programs

So, I'm a brand new CS student, on a Mac, and I'm learning C++ for one of my classes. And I have a dumb question about how to compile my super basic C++ program. I installed Xcode, and I'm looking through the documentation to try and figure out how to use it (and I highly suspect it's extremely overpowered for what I'm doing right now)...

Using gcc along with ccache

Hi, I was thinking about using ccache with gcc compiled code on the team wide base (same ccache's cache will be used by all developers on the same machine). Since we're talking about commercial product, "correctness" of compilation is a top priority. Here come questions: Is the compilation using ccache is safe/reproducible? Is there...

scite editor and gcc setting up?.

Hey there, In class we're using the Scite editor with gcc and its a tad outdated. I was wondering how you would "attach"(For lack of a better term) gcc to scite so that it would compile the code when I hit the compile icon?. Also would this process be the same when using other text editors like notepad++. -cheers. ...

How do I compile a GNUstep application that uses NSApplication on Windows?

I am exploring with compiling an application with GNUstep on Windows. This is my main.m file: #import <???/???.h> int main(int argc, const char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApplication sharedApplication]; [pool release]; } I realize this is an incomplete fragment to say the le...

Xcode/GCC predefined macro for target name?

I was wondering if there is an Xcode or GCC preprocessor symbol for the target name of the application. For example if I'm building an application called "MonkeyChicken", is there a preprocessor symbol such that printf( __TARGET_NAME__ ) outputs: MonkeyChicken ...