gcc

What is libg2c library?

I have found the code which links against of 'g2c' library. Why do I need it? Just would like to understand why it might be important and what it does in general. Thanks! ...

how to define a string in gcc command line?

In gcc command line, I want define a string for source code. line -Dname=Mary. then in the source code I want printf("%s", name); to print Mary. How could I do it? Thanks ...

How can I get the source lines inline with the assembly output using GCC?

I'd like to get the C source lines inline with the assembly output to see what code is being generated. I have tried GCC options like -S -Wa,-ahlms (and even -Wa,--gstabs 'cause I read it somewhere). Oh! BTW, I am on a Mac so I don't have objdump. (Sorry this is short, I have to get off the train!) Output of gcc pc-clisp.c -S -g -fve...

Linker throwing out undefined symbol

I'm building an executable using GCC 3.4.0 . The target is an embedded system. I've been using a way of modularly defining "console command handlers" by defining a function pointer to a handler in any compilation unit to be in a certain linker section. At runtime when a command is entered on the console I can loop through all the handler...

Cocoa Touch & Sql Server

Is it possible to connect to Sql Server for the purpose of executing simple Sql commands within a native iPhone app? If so, how does one go about it? I'm stumped. More generally, I would at least like to see how this is done with GCC. Thanks in advance, Rich ...

gcc, make: how to disable fail on warning?

I'm trying to build gcc for use with an AVR micro controller and avr-ada, and I've hit a roadblock caused by my regular compiler being too picky about the version I needed for the AVR. I get the following warning, which in turn causes the gcc or make to report an error: gcc -c -g -O2 -gnatpg -gnata -nostdinc -I- -I. -Iada -I../../gc...

Sharing Multiple Variables Via sys/shm.h

Hi there, I am trying to share two different using one shared memory block using the shm.h library. I wrote the following example, where one shared memory block is created and is big enough to hold two integers. I then attach two integers to it and create two processes. The first process increments the first integer. The second process ...

What does '__asm__(".previous");' mean?

Hello everyone. While trying to compile my project, that uses some third party headers, with mingw 4.4, I encountered the following error: Assembler messages: Error: junk at end of line, first unrecognized character is '"' Error: unknown pseudo-op: '.previous' I found this code at the end of one of the included headers: __asm_...

What's the shortest code to write directly to a memory address in C/C++?

I'm writing system-level code for an embedded system without memory protection (on an ARM Cortex-M1, compiling with gcc 4.3) and need to read/write directly to a memory-mapped register. So far, my code looks like this: #define UART0 0x4000C000 #define UART0CTL (UART0 + 0x30) volatile unsigned int *p; p = UART0CTL; *p &= ~1; Is t...

makefile using custom directory and library

Hello, I wrote a makefile: all: server client server: server.o des.o sha1.o /usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o server server.o des.o sha1.o -I /usr/local/include/ -lgmp client: client.o des.o sha1.o /usr/local/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -o -lgmp client client.o des.o sha1.o -I /usr/local/include/ s...

Standard Buffer not getting cleared before system() call

#include<stdio.h> #include<signal.h> #include<stdlib.h> void handler(int signo) { printf("First statement"); system("date"); exit(EXIT_SUCCESS); } int main() { signal(SIGINT,handler); printf("Waiting for KeyboardInterrupt\n"); for(;;); return 0; } Test run:- shadyabhi@shadyabhi-desktop:~/c$ gcc main.c shad...

gcc -fvisibility problem

I have the problem described here: http://gcc.gnu.org/wiki/Visibility Exception class exported from shared library cannot be caught when used outside of the library, and the program terminates. I added __attribute__((visibility("default"))) to the class declaration: class __attribute__((visibility("default"))) MyException { ... ...

Can nullptr be emulated in gcc?

I saw that nullptr was implemented in Visual Studio 2010. I like the concept and want to start using it as soon as possible; however GCC does not support it yet. My code needs to run on both (but doesn't have to compile with other compilers). Is there a way to "emulate" it? Something like: #define nullptr NULL (but obviously that wou...

Listing C Constants/Macros

Is there a way to make the GNU C Preprocessor, cpp (or some other tool) list all available macros and their values at a given point in a C file? I'm looking for system-specific macros while porting a program that's already unix savvy and loading a sparse bunch of unix system files. Just wondering if there's an easier way than going hun...

Exceptions are not caught in GCC program

My project contains shared library and exe client. I found that my own exception class thrown from the library is not caught by client catch block, and program terminates with "terminate called after throwing an instance of ..." message. Continuing to play with the project, I found that any exception of any type is not caught. For exampl...

OSX/Darwin unresolved symbols when linking functions from <math.h>

I'm in the process of porting a large'ish (~1M LOC) project from a Window/Visual Studio environment to other platforms, the first of which happens to be Mac OS X. Originally the project was configured as Visual Studio solutions and projects, but now I'm using (the excellent) Premake (http://industriousone.com/premake) to generate proje...

When should -m32 option of gcc be used?

I am writing a program which if I compiler on Suse 10 32 bit system without adding the -m32 option and execute it on Suse 10 64 bit works fine. In this case is it not required for me to add -m32 option? Can we execute programs built on 32 bit systems directly on their 64 bit counterparts without any side-effects? Or any updates or cha...

LIBPATHS not being used in Makefile, can't find shared object

I'm having trouble getting a sample program to link correctly (in this case against the ICU library). When I do 'make', everything builds fine. But when I run it, it says it can't find one of the .so's. I double checked they're all installed in /usr/local/lib. What I discovered was it was looking in /usr/lib. If I symlink from there to t...

Compile time comparison between Windows GCC and MSVC compiler

We are working on reducing compile times on Windows and are therefore considering all options. I've tried to look on Google for a comparison between compile time using GCC (MinGW or Cygwin) and MSVC compiler (CL) without any luck. Of course, making a comparison would not be to hard, but I'd rather avoid reinventing the wheel if I can. D...

With g++ is there a runtime setting to scramble freed memory with delete?

Does anyone know how I can for the g++ or gcc runtime to scramble the ram where an object was after delete? I have a theory that I'm using an object after it has been deleted but in practice it rarely crashes. ...