c

gdb: set a breakpoint for a SIGBUS handler

I'm trying to debug a simple stop-and-copy garbage collector (written in C) using GDB. The GC works by handling SIGBUS. I've set a breakpoint at the top of my SIGBUS signal handler. I've told GDB to pass SIGBUS to my program. However, it doesn't appear to work. The following program (explained inline) shows the essence of my problem: #...

Are open streams automatically flushed and closed on SIGINT in C?

I've read in a man page that when exit() is called all streams are flushed and closed automatically. At first I was skeptical as to how this was done and whether it is truly reliable but seeing as I can't find out any more I'm going to accept that it just works — we'll see if anything blows up. Anyway, if this stream closing behavior is ...

Volatile Struct Semantics

Is it sufficient to declare an instance of a structure-typed variable as volatile (if its fields are accessed in re-entrant code), or must one declare specific fields of the structure as volatile? Phrased differently, what are the semantic differences (if any) between: typdef struct { uint8_t bar; } foo_t; volatile foo_t foo_inst; ...

IEEE - 754 - find signbit, exponent, frac, normalized, etc..

I am taking in a 8 digit hexadecimal number as an IEEE 754 bit floating point number and i want to print information about that number( signbit, expbits, fractbits, normalized, denormalized, infinity, zero, NAN) floating point should be a single. I read up on bit shifting, and i think this is how i am suppose to do it?. however, i am no...

libexif example to add a small Xml document in the exif data

Any libexif user/developer that could point me in the right direction on what are the appropriate call for adding a small custom XML document in the exif meta data of a JPG image ? I have been googling around for a while and can't figure it out. I am open to any other opensource library that will let me do that as long as it is C based...

Newbie C #include Question

I roughly understand the rules with what #include does with the C preprocessor, but I don't understand it completely. Right now, I have two header files, Move.h and Board.h that both typedef their respective type (Move and Board). In both header files, I need to reference the type defined in the other header file. Right now I have #incl...

How can I get the filesystem page size from unix/linux/osx and windows?

I want to be able to determine at runtime what the sector size is for a give filesystem. C code is acceptable. for example I format my Data partitions with a 32k sector size that have lots of large video files. I want to be able to get this value at runtime. ...

How to save settings in gdb?

Hello, Does anyone know how to save gdb settings (like "set print pretty on" or "set print elements 0", both from here)? I don't want to set my configuration every time that I will use gdb :/ I searched in google and SO, but I found nothing. Thanks. ...

Memoization in static Objective-C class

Say I have a class method like + (double)function:(id)param1 :(id)param2 { // I want to memoize this like... static NSMutableDictionary* cache = nil; // // test if (param1,param2) is in cache and return cached value, etc. etc // } Thanks!! ...

Developing C wrapper API for Object-Oriented C++ code

I'm looking to develop a set of C APIs that will wrap around our existing C++ APIs to access our core logic (written in object-oriented C++). This will essentially be a glue API that allows our C++ logic to be usable by other languages. What are some good tutorials, books, or best-practices that introduce the concepts involved in wrappin...

MPQueue - what is it and how do I use it?

I encountered a bug that has me beat. Fortunately, I found a work around here (not necessary reading to answer this q) - http://lists.apple.com/archives/quartz-dev/2009/Oct/msg00088.html The problem is, I don't understand all of it. I am ok with the event taps etc, but I am supposed to 'set up a thread-safe queue) using MPQueue, add ...

Input year, then print calendar

Hi, I am stuck on the following problem from my C programming class: Write a program that prompts the user to input a year, and then outputs the calendar(for the entire year). I have no idea how to approach this problem. I can usually start my homework problems (this is an optional challenge problem), but I am really lost. We've wor...

C ints and chars. Strange behavior

Hi, I am learning C language and I am facing a problem I don't seem to be able to resolve on my own. I have a simple loop where I add up ascii values of all characters in each word. char char_array[100]; int lexicographical_values[20]; int i, j = 0; for( i = 0; i <strlen(char_array); i++) { if(char_array[i] ==...

Questions About Defined Numbers Of a Header File

I never tried to do a GUI without a GUI designer and now I'm learning how to develop Palm OS applications with the book Palm OS Programming: The Developers Guide. And on it I have this code that is a declaration of some GUI items: #define HelloWorldForm 1000 #define HelloWorldButtonButton 1003 #define HelloWorldMenuBar 1000 #define Goo...

from file object to file name

Hi, I wonder if we can get the file name including its path from the file object that we have created for the file name in C and in C++ respectively FILE *fp = fopen(filename, mode); // in C ofstream out(filename); // in C++ ifstream in(filename); // in C++ Thanks! ...

compiling various header files in c using autotools in arch linux

i would like to know how can i compile a number of header files by just one command using autotools in arch linux ...

What are the most useful new features in C99?

C99 has been around for over 10 years, but support for it has been slow coming, so most developers have stuck with C89. Even today, I'm sometimes mildly surprised when I come across C99 features in C code. Now that most major compilers support C99 (MSVC being a notable exception, and some embedded compilers also lagging behind), I feel ...

Profile a C shared library called by Ruby program

I have a program written in Ruby and C. The C portion is a shared library, which is an extension for the Ruby program. I want to profile the C shared library I wrote, using gprof. I compile the shared library like this: gcc -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-al...

Is there a wide character version of stat() (from sys/stat.h)?

I have been using stat() for checking the existence of a file, which I understand is better practice than trying to open a file. However, stat() doesn't work for filenames containing unicode characters in other languages. Is there a wide character version of stat(), or something equivalent that I can use? If not, what is the next accep...

C/Assembler - Return code in a single-user, single-task operating system without stack

I have a simple bootloader, which initializes and prepares SDRAM. Then it loads an application from the Flash and starts it at some address in the RAM. After the application has finished its execution, the system does restart. There is no system stack. Now, I would like this bootloader receives control back after an application finished...