gcc

gcc and g++ command prompt compiling and linking

Hey there, I have a small problem with compiling and linking with the command prompt(windows xp). Every .c file and .cpp file I compile or link has to be in the same directory as gcc (C:\Program Files\gcc\bin) and its quite hard to keep track of my files among all those gcc related files and its annoying too:). My question is how do I co...

Virtual inheritance - gcc vs. vc++

Hi all! I have a problem with Visual Studio 2008 concerning virtual inheritance. Consider the following example: #include<iostream> class Print { public: Print (const char * name) { std::cout << name << std::endl; } }; class Base : public virtual Print { public: Base () : Print("Base") {} }; class A : ...

C++ iterators breaking in Visual C++ but not GNU g++

I am trying to learn more about list containers and how to iterate through them, but it seems that g++ has no problem with it, but Visual Studio C++ pukes all over the place! #include <iostream> #include <string> #include <list> using namespace std; int main(){ list <string> data; list <int>::iterator it; data.push_back("fe...

Can gcc/gcov be made to output coverage stats to a location other than the source folder?

When using gcc with -fprofile-arcs and -ftest-coverage, when the resulting executable terminates, it tries to create .gcda output files in the same location as the .o files used to compile the executable. This is inconvenient when I'm running on a different machine than the one I built on -- is there any way to change this behaviour? ...

likely/unlikely equivalent for MSVC

GCC compiler supports __builtin_expect statement that is used to define likely and unlikely macros. eg. #define likely(expr) __builtin_expect((expr), !0) #define unlikely(expr) __builtin_expect((expr), 0) Is there an equivalent statement for the Microsoft Visual C compiler, or something equivalent ? ...

gdb breakpoint on pthread_create

I am trying to set a breakpoint in linux in gdb for a program creating threads. I would like to set a breakpoint on thread creation, but unfortunately pthread_create is a versioned symbol, and I can't get its full name. If I type: catch thread_start I get Catch of thread_start not yet implemented How is the best way to catch thre...

Python subprocess.Popen - adding GCC flags results in "no input files" error

I'm building a Python script to automate my build process, which invokes GCC using subprocess.Popen. My initial attempt works fine. >>> import subprocess >>> p = Popen(['gcc', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT) >>> p.wait() 0 >>> p.communicate() ('', None) However, once I pass additional options to G...

How to install pysqlite?

Hi all, I am trying to install pysqlite (Python interface to the SQLite). I downloaded the file with the package (pysqlite-2.5.5.tar.gz). And I did the following: gunzip pysqlite-2.5.5.tar.gz tar xvf pysqlite-2.5.5.tar \cd pysqlite-2.5.5 python setup.py install At the last step I have a problem. I get the following error message: er...

Eclipse CDT on Snow Leopard cannot find binaries

After upgraded to Snow Leopard, I can no longer run Eclipse CDT project on my computer. While the build process completes without any error, Eclipse does not recognize the binary file it created. When try to point to the binary file in Run Configuration.. dialog, it cannot find any binary in the project. Though executing the file from Te...

Code that compiles for the iPhone Device but not for the Simulator

I am using C++ to develop the algorithmic part of an iPhone application, and I am encountering a strange bug. The code that I have, compiles fine with gcc-4.2 both on Linux, on the Mac, and on the iPhone device, just not on the Simulator, which makes debugging and testing very difficult. The error messages from the attempts to compile ...

Installing gtk and compiling using gcc under windows?

I have gcc installed in c:/programfiles (also set as a path variable), and i have all the necessary files for gtk from http://www.gtk.org/download-windows.html, glib,gtk,pango,atk and cairo. Although I have no clue as to how to compile a c program using gtk with the gcc compiler. How do I set everything up so that it works?. (I don't kno...

Forcing inclusion of static library object files that don't export any symbols (GCC/iPhone)

Hi, I'm creating a static library for use in iPhone applications. It contains a number of source files which export no symbols, all they do is instantiate a static instance of a class which then runs some code in its constructor that registers various things with a central manager class elsewhere. This all works fine when the code is bu...

-forwardInvocation works with Clang - LLVM but not with GCC

The following code implements an NSProxy subclass which forwards methods to an NSNumber instance. However when calling [nsproxy floatValue] I get 0.0 under GCC 4.2. Under LLVM-Clang I get the correct answer 42.0. Any idea what is going on? (by the way this is running under Garbage Collection) -(id) init; { _result = [NSNumber nu...

Disable all gcc warnings

I'm working on a project that will read compiler error messages of a particular variety and do useful things with them. The sample codebase I'm testing this on (a random open-source application), and hence rebuilding frequently, contains a few bits that generate warnings, which are of no interest to me. How do I disable all warnings fro...

C++ struct alignment question

I have a predefined struct (actually several) where variables span across 32-bit word boundary. In Linux (and Windows using GCC) I am able to get my structs to pack to the correct size using 'attribute((packed))'. However I cannot get it to work the same way using VC++ and #pragma pack. Using GCC this returns a correct size of 6 bytes...

Mac OSX 10.6 compiler: a puzzling experience with 32 vs 64 bit.

I have trouble understanding the gcc compiler provided by OSX 10.6 snow leopard, mainly because of my lack of experience with 64 bits environments. $ cat >foo.c main() {} $ gcc foo.c -o foo $ file foo foo: Mach-O 64-bit executable x86_64 $ lipo -detailed_info foo input file foo is not a fat file Non-fat file: foo is architecture: x86_64...

How to disable address space randomization for a binary on Linux?

I'm working on a runtime system for parallel programs that can take advantage of a common address space layout across multiple processes, potentially spread over several (thousand) nodes. Many times, software built for this environment is run on Linux systems that have address space randomization enabled by default, and users may not wan...

How to detect an overflow in C++ ?

Hi, I just wonder if there is some convenient way to detect if overflow happens to any variable of any default data type used in a C++ program during runtime? By convenient, I mean no need to write code to follow each variable if it is in the range of its data type every time its value changes. Or if it is impossible to achieve this, h...

Tint2 Compilation

I'm on a network where I don't have root access, so everything I install is under a prefix ~/bin (actually referenced by its full path). So I have openbox working fine, which is what I'm using to send this from. Imlib2 I do ./configure --prefix=~/bin; make; make install. Then I run from the tint2 source directory IMLIB2_CFLAGS=-i~/bin/i...

How can i make GNAT generate program listing?

Make it look like tasm-generated listing) ...