gcc

Meaning of C++0x auto keyword, by example?

Hello, auto a = (Foo<T>*)malloc(sizeof(Foo<T>)); auto *b = (Foo<T>*)malloc(sizeof(Foo<T>)); I don't think it's important that templates are there, but the question is: are a and b of the same type? g++ -std=c++0x -Wall (4.4) doesn't give any errors or warnings, but I haven't run the program so I don't know if it does the same thing. ...

gcc -x objective-c with Android SDK

Since Objective-C exists and is supported even in MinGW, by passing -x objective-c, is there a hack to achieve this with Android SDK? I've did a rudimentary test on a colleague's machine where it appears that language objective-cis not supported. I am not interested in getting UIKit or AppKit, or even Foundation, to work; I've written m...

Why is there a switch in the CPU core usage when I run this C code?

When I ran this code using gcc, $ cat eatup.c #include<stdio.h> #include<stdlib.h> int main() { int i = 0; while(1) { i++; } } $ the CPU graph went like this : I am not sure why there is a cross in the CPU core usage. I started the run at the rise to the left of the 40 mark, then initially core2 usage rose to...

gcc, include file dependencies

hello Is there option (or some utility) to generate graph of dependencies for given file? I am trying to track down who brings an include file into compilation unit. ...

How to Build a 32-bit Python Module Distribution w/ Setup.py on x86_64 Host

I need to compile a 32-bit distribution of PyEphem. It does not seem like this should be difficult, however, I'm running into some compiler issues. $ CFLAGS=-m32 python setup.py bdist -p i386 running bdist running bdist_dumb running build running build_py running build_ext building 'ephem._libastro' extension gcc -pthread -fno-strict-al...

Pragma message in Clang?

What's Clang's equivalent to #pragma message as used in GCC and MSVC? ...

Using '>>' across gcc and visual c++

We are writing an application that compiles with both gcc and Visual C++. Some team members only use Visual C++/Windows, and others only use gcc/linux. Due to differences between compilers the build sometimes breaks. I have "fixed" several scenarios that lead to build breaks using compiler options to enable/disable warnings, but currentl...

How can I compile GCC on a mac so compiled executables will work on earlier versions of OS X?

I'm attempting to build a program (Dwarf Fortress) that uses C++0x features that aren't well supported in the latest Leopard version of XCode. As there is also a significant speed boost from using GCC 4.5, we've decided to build our own. However, this causes the resulting executables to not work on Tiger, citing missing symbols in libc....

Specify a number literal as 8 bit ?

unsigned char ascii; int a = 0; char string[4] = "foo"; "A1" ascii = (string[a] - 'A' + 10) * 16; warning: conversion to ‘unsigned char’ from ‘int’ may alter its value It seems that gcc considers chars and number literals as int by default. I know I could just cast the expression to (unsigned char) but how can I specify char lite...

Why didn't -O3 GCC Optimization inline this function?

In GCC compiler, whenever -O3 is flagged, the compiler optimizes mainly by Loop Unrolling and Function Inlining. However, when I compiled an application that has the following function, it didn't do Function Inlining. From gprofing and gconving I could notice that this function (comp_t_delay) was not called from the main function unit o...

ld: library not found for -lcrt0.o on OSX 10.6 with gcc/clang -static flag

When I try to build the following program: #include <stdio.h> int main(void) { printf("hello world\n"); return 0; } On OS X 10.6.4, with the following flags: gcc -static -o blah blah.c It returns this: ld: library not found for -lcrt0.o collect2: ld returned 1 exit status Has anyone else encountered this, or is it something...

Understanding this erratic behavior in gdb

Consider the following code: #include <stdio.h> #include <ctype.h> char* Mstrupr(char* szCad); int main() { char szCadena[] = "This string should print well."; printf("%s\n", Mstrupr(szCadena)); printf("%s\n", Mstrupr("This string should fail.")); return 0; } char* Mstrupr(char* szCad) { int i; for (i=0; szC...

gcc Error: "Inputtools.c:85: error: conflicting types for ‘strcasestr’"

I tried compiling ADPACK, written in C, on an Intel Mac running OX 10.6.4. I got the following error from the make command. gcc -I/usr/local/include -I/home/ozaki/include -c adpack.c adpack.c: In function ‘main’: adpack.c:223: warning: incompatible implicit declaration of built-in function ‘strlen’ gcc -I/usr/local/include -I/home/ozaki...

How to get a pointer to a binary section in MSVC?

I'm writing some code which stores some data structures in a special named binary section. These are all instances of the same struct which are scattered across many C files and are not within scope of each other. By placing them all in the named section I can iterate over all of them. In GCC, I use _attribute_((section(...)) plus some ...

How do I tell `gar` or `ar` to output `elf32-i386` output?

When I look at the help output from gar -h, it tells me: [...] gar: supported targets: elf64-x86-64 elf32-i386 a.out-i386-linux [...] How can I instruct gar to create an elf32-i386 output? ...

dlclose problem

plugin1.cpp: #include <iostream> static class TestStatic { public: TestStatic() { std::cout << "TestStatic create" << std::endl; } ~TestStatic() { std::cout << "TestStatic destroy" << std::endl; } } test_static; host.cpp #include <dlfcn.h> #include <iostream> int main(int argc,char argv*[]) { void* handle = dlop...

Unknown GCC error, while compiling for ARM NEON (Critical)

Hi Guys, I have a ARM NEON Cortex-A8 based processor target. I was optimizing my code by making use of NEON. But when I compile my code I get this strange error. Don't know how to fix this. I'm trying to compile the following code (PART 1) using Code Sourcery (PART2) on my host. And I get this strange error (PART3). Am I doing somethi...

Undefined reference to static member

I have a static member in my class. It's declared and defined: In my header: class Bla { ... static Bla* instance; ... }; In my implementation file: Bla::Bla* instance = 0; But ld doesn't seems to like it: release/bla.o:bla.cpp:(.text+0x19f7): undefined reference to `Bla::instance' I'm using GCC 4.4.0 from the Qt SDK. I can't ...

readline clash with child printf?

In Linux, readline() in an infinite loop repeatdly reads text\n. However, as soon as child processes start printing to the screen, readline no longer reads new lines. Even if I repeatdly press enter, readline() doesn't return. Anyone know what's wrong? Code sample as requested: char* input; int cpid; while(1) { input = readline("...

gcc switches - what do these do?

I am new with using gcc and so I have a couple of questions. What do the following switches accomplish: gcc -v -lm -lfftw3 code.c I know that lfftw3 is an .h file used with code.c but why is it part of the command? I couldn't find out what -lm does in my search. What does it do? I think I found out -v causes gcc to display program...