c

What are the differences between poll and select?

I am referring to POSIX standard of select and poll system C API calls? ...

Resources for cross-platform C/C++ development

What resources exist to aid in writing C/C++ code that works across multiple platforms and compilers? For example, I regularly find myself asking questions like: Which preprocessor macros are automatically defined in various compilers and environments? (e.g. __GCC__, WIN32, __WIN32__, __CYGWIN__) Which versions of compilers and standar...

Can the signal system call be used with C++ static members of the class?

Is the following supported across *nix platforms? #include <cstdio> #include <sys/types.h> #include <signal.h> #include <unistd.h> class SignalProcessor { public: static void OnMySignal(int sig_num) { printf("Caught %d signal\n", sig_num); fflush(stdout); return; ...

How can I put a pointer on the pipe?

Say I have a pointer to some structure in a thread, and I want to pass it to the parent process via a pipe. Example: MyType * someType; I then want to cast someType to void * and put it on the pipe. How can it be done? ...

Refactoring build system to use Autotools

Over the past couple of days I have been reading into using autotools to build my project instead of the Makefiles I have pieced together over the past couple of months. Unfortunately I have not found an example that gave me enough insight towards how my project structure is currently. I have three libraries that are included in the app...

How can I pass data from a thread to the parent process?

I have a main process that uses a single thread library and I can only the library functions from the main process. I have a thread spawned by the parent process that puts info it receives from the network into a queue. I need to able to tell the main process that something is on the queue. Then it can access the queue and process the ...

Building windows forms in C

So far, I've been able to create a window in C, and add a button and edit box to that window. But, where can I find an exhaustive list of the system classes for all the form controls? I can't remember where I found BUTTON and EDIT--is there a LABEL? LISTBOX? CHECKBOX? COMBOBOX? etc. Then, how would I use those built in windows functions...

Efficient way to make a Programmatic Audio Mixdown

I'm currently working on the iPhone with Audio Units and I'm playing four tracks simultaneously. To improve the performance of my setup, I thought it would be a good idea to minimize the number of Audio Units / threads, by mixing down the four tracks into one. With the following code I'm processing the next buffer by adding up the samp...

AT&T vs Intel Syntax and Limitations?

To me, Intel syntax is much easier to read. If I go traipsing through assembly forest concentrating only on Intel syntax, will I miss anything? Is there any reason I would want to switch to AT&T (outside of being able to read others' AT&T assembly)? My first clue is that gdb uses AT&T by default. If this matters, my focus is only on any...

Where might I obtain a lexical analyzer capable of reporting for-loop errors in C or C++?

I need a simple lexical analyzer that reports for-loop errors in C/C++. ...

Single linked list

Hello, I have created a single linked list. Everything works fine. I just want to know if I have done anything potentially dangerous in my code. The code snippets I am concerned about is my push, pop, and clean-up. The parts of the code is just for user interaction so not really important (I posted anyway so that it was more clear in ...

implication of private in C

What is the implication of "private unsigned char" in C? ...

How to write own Configformat

Hi there, I've developed an own file format for configuration files (plaintext and line based -> EOL = one configuration) for an application. This format is nothing quit special and the only reason I do this, is to learn something! The reader and writer functions will be implemented in C (with GLib because it should be a UTF8 encoded fi...

Stack unwinding on HP-UX and Linux

I need to get the stack information of my C application in certain points. I've read the documentation and searched the Net but still cannot figure out how I can do it. Can you point to a simple process explanation? Or, even better, to an example of stack unwinding. I need it for HP-UX (Itanium) and Linux. Thanks ...

how to easily create videos in c from a series of cairo canvases?

I'm writing some physics simulations in c for university, and now I output a series of hundreds of png that I then watch in fast sequence... is there a way to merge them to a video in c with some simple lossless codec library? P.S. I'm using cairo graphics and have very little experience in graphics programming in general ...

Use C switch statement for error handling

Consider this C construct that checks for errors before doing actual work: int function(struct Context *context,struct Connection *conn) { int retval; switch(0) { case 0: retval = BUFFER_INACTIVE; if(conn->mSocket == -1) break; retval = BUFFER_FULL; /* Is there enough room to add ? */...

How to Enforce Exactly One Definition?

Given a C project that needs to support multiple environments, how do I use the preprocessor to enforce that exactly one environment is defined? I can already do #if defined PROJA (blah blah blah) #elif defined PROJB (etc) #else #error "No project defined" #endif All that does, though, is tell me if 0 pro...

Why can't I assign a const value, and what should I do instead?

I have a piece of code with the following rough signature: void evaluate(object * this) { static const int briefList[] = { CONSTANT_A, CONSTANT_Z }; static const int fullList[] = { CONSTANT_A, CONSTANT_B, ..., CONSTANT_Z}; const int const * pArray; const int nElements; int i; if ( this->needDeepsEvaluation ) ...

C Programming: seg faults, printf, and related quirks

As many young programmers do, I learned the usefulness of inserting numerous print-to-console statements of "here1," "here2," and so on at different points in code to figure out when my programs are going awry. This brute force debugging technique has saved me many, many times throughout my CS studies. However, when I started programming...

how to code drivers?

I want to code drivers in C in linux os, though I think its very tough. Can I get some hints as to how to start or books to follow? Drivers can be from my USB port to graphics card!! I know as to where I can search for books, I would like to know as to what the basic knowledge I should start with. Do I need to have hardware knowledg...