gcc

Objective-C syntax checker

Is there an Objective-C syntax checker? I have tried gcc -fsyntax-only but it is not really 'syntax only'. It still produces errors if run on an individual implementation file which has references to external frameworks. I am looking for something that can perform a syntax check on individual header or implementation files without att...

Is it possible to prevent an RAII-style class from being instantiated "anonymously"?

Suppose I have an RAII-style C++ class: class StateSaver { public: StateSaver(int i) { saveState(); } ~StateSaver() { restoreState(); } }; ...to be used like so in my code: void Manipulate() { StateSaver save(1); // ...do stuff that modifies state } ...the goal being to enter some state, do stuff, then leave that sta...

Help with GCC and ObjectiveC code and Cygwin

Is it possible to build objective c code correctly with GCC under cygwin. I have the following application that should work on a Mac environment, but can't get the most basic stuff to work with gcc. Are there more libraries I need to have. #import "HelloWorldApp.h" int main(int argc, char *argv[]) { return 0; } // End of the //...

Question about storing array in a std::vector in C++

I am unclear about the following. First, this code compiles fine: #include <vector> typedef struct{ int x1,x2,x3,x4; } ints; typedef std::vector<ints> vec; int main(){ vec v; ints a = {0,1,2,3}; v.push_back(a); } The following code is near identical: #include <vector> typedef std::vector<int[4]> vec; int main(){ vec v; i...

__attribute__ ((__aligned__)) not working with static variables

This has been driving me nuts for days. I can't get an array to align to 16 if I declare it as static. Any help greatly appreciated. Revised Version: #include <stdio.h> #include <assert.h> #define MAX_INPUTS 250 int main() { float input[MAX_INPUTS] __attribute__ ((__aligned__(16))); printf("Address of input: %p\n", input); printf("...

how can I link against libpython.a such that later the runtime linker can find all the simbols in libpython.a?

In a sequel question to this question, my corporate environment lacks the libpython2.6.so shared object but has the libpython2.6.a file. Is there a way that I can compile in libpython2.6.a while retaining the symbols in libpython2.6.a such that dynamic libraries can find these symbols at runtime? My current compile with the static libr...

How can I tell gcc not to inline a function?

Say I have this small function in a source file static void foo() { } and I build an optimized version of my binary yet I don't want this function inlined (for optimization purposes). is there a macro I can add in a source code to prevent the inlining? thanks ...

How to link Tiger's SQLite3 library in Xcode?

I have been working on a project which uses Tiger's SQLite3 library (which if I remember well is contained in CoreData.framework?) and came across a problem when building with the "Release" config. I get linking errors telling me the sqlite3 symbols I use through my project are undefined. I'm pretty sure this is due to the needed sqlite3...

Building GCC cross compiler (from "Linux" to "Windows")

Hello, I want to build "gcc cross-compiler" to compile "c/c++" applications on "Linux" environment but for "Windows" target. I have made this so far: Installed the necessary tools and packages for building GCC listed on "Prerequisites for GCC" page. Downloaded required sources: "gcc-core-4.4.1", "gcc-g++-4.4.1", "binutils-2.19.1", "w...

Compiling with gcc (cygwin on windows)

I have cygwin on windows through which I run gcc. But after creating .exe files, if I run them on other computers which dont have cygwin, it says cygwin1.dll not found. Is there a way to compile them so that they run on any system? ...

fork with gcc on windows

I am using fork in my program on windows using gcc (cygwin). It runs fine on my system. but I want to run on other systems which dont have cygwin. How can I do that? ...

C++ pragma directive

What this C++ directive do: "#pragma GCC system_header"? ...

Linux assembler error "impossible constraint in ‘asm’"

I'm starting with assembler under Linux. I have saved the following code as testasm.c and compiled it with: gcc testasm.c -otestasm The compiler replies: "impossible constraint in ‘asm’". #include <stdio.h> int main(void) { int foo=10,bar=15; __asm__ __volatile__ ("addl %%ebx,%%eax" : "=eax"(foo) : "eax"(foo), "ebx"(...

Linux runtime linker error

Hi All - I'm working though the First Steps tutorial on the POCO Project site, and I've successfully built the library (Debian Linux, 2.6.26, gcc 4.3.2) under my home directory ~/Development/POCO with the shared libraries located in ~/Development/POCO/lib/Linux/x86_64/lib My problem is that any application I build that depends on t...

Clean x86_64 assembly output with gcc?

I've been teaching myself GNU Assembly for a while now by writing statements in C, compiling them with "gcc -S" and studying the output. This works alright on x86 (and compiling with -m32) but on my AMD64 box, for this code (just as an example): int main() { return 0; } GCC gives me: .file "test.c" .text .globl main .type main...

C++: Including header-file fails compilation but including source cpp file compiles.

This is probably really simple, but it's hindering me on my way down c++ road. I am currently reading through accelerated c++ and I decided to overkill one of the exercises. It all worked well and my code ran fine until I split it into a header and separate source file. When I import my .cpp source file containing some functions I wrote,...

Is it safe to use fastcall in a shared library?

For example, let's say I have a function that will swap bytes in a 32 bit value for you: uint32_t byte_swap(uint32_t in); Well it seems silly to push that 32-bit value onto the stack and pop it off again, especially if we're going to be calling this function a lot, so let's pass it in through ECX: #if __FASTCALL_SUPPORTED_ /* Whate...

why only my first x forks make the job (gcc)

before you ask... this is from my study guide. From my perspective this is almost done but I can't put it working in the way I want. the exercise is: given an string fork X times and print one character per child until the the string finish. this is the code and compiles: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #inc...

How do I make a simple makefile? GCC Unix

Hi have three files. program.c, program.h, and headers.h program.c #includes program.h and headers.h I need to compile this on Linux using gcc compiler. I'm not sure how to do this. Netbeans created one for me, but it's empty. ...

How do i compile this code to work with LD_PRELOAD on linux?

How do I compile the following code for make it work with LD_PRELOAD?. I managed to compile it w/o errors with 'gcc -m32 -shared code.c' but when I open the program that I'm trying to 'inject' the code into, it says this: 'symbol lookup error: ./fps.so: undefined symbol: clock_gettime' #include<unistd.h> #include<time.h> #define BUSY_WA...