c

Defining function macros

Hello, gcc 4.4.1 C99 I have written a function that I will use for displaying messages to the user. This works ok, and I will need it to be scalable as I will have more error codes to add later. However, the inputs will be the priority, error_code, and a short description of the error. I have included the function, and the line number...

How is a union different from a struct? Do other languages have similar constructs?

Possible Duplicate: Difference between a Structure and a Union in C I see this code for a union in C: union time { long simpleDate; double perciseDate; } mytime; What is the difference between a union and a structure in C? Where would you use a union, what are its benefits? Is there a similar construct...

Is it possible to use opendir repeatedly in C?

I am trying to debug right now in C and am curious if it is alright to call opendir() repeatedly without having to first call closedir() because I am trying to run a loop to open sub-directories when the while-loop that calls readdir() encounters them. And I assume that closing the current directory would cause me to lose the ability to ...

Are there C/C++ compilers that do not require standard library includes?

All applicants to our company must pass a simple quiz using C as part of early screening process. It consists of a C source file that must be modified to provide the desired functionality. We clearly state that we will attempt to compile the file as-is, with no changes. Almost all applicants user "strlen" but half of them do not inc...

visual studio plugins for C++ environment

hi there 1) I'm new into C/C++ development using Visual Studio 2008 and after some searches here i didn't find any posts related to C/C++ Visual Studio plugins besides Visual Assist X?(there are a lot of posts related to C# and asp VS environments). 2) The right approach about learning how to use those tools is to learn/try them one ...

Is there a C or C++ embeddable library for reading email through pop ?

I'm looking for a not too big C or C++ library that would allow to read email through pop on Windows. The smallest the better. It would be better if it could support SSL. ...

Access variables in C structures

Dear all! I am not too familiar with C programming, and I have to do few modifications on a source code, here is the problem: I have this in a header file : typedef struct word { long wnum; float weight; } WORD; typedef struct svector { WORD *words; double norm; } SVECTOR; In my file.c , I have a function like doubl...

JNA/ByteBuffer not getting freed and causing C heap to run out of memory

Let me start by saying that my understanding of how JNA and Java direct native memory allocations is visceral at best, so I'm trying to describe my understanding of what's going on. Any corrections in addition to responses would be great... I'm running an application that mixes Java and C native code using JNA and am running accross a ...

What are some open-source applications written in C/C++ using PostgreSQL?

I'm trying to find open source applications using PostgreSQL that are written in C/C++ so I can study them. A few open source projects using PostgreSQL are Evergreen ILS, SpamAssassin, and pgpool. However, Evergreen and SpamAssassin are written in Perl, and pgpool (written in C) is a replication tool, not a typical application. Moreov...

EXT3 Error Running Inside VMWare

I'm doing development of an OS based on the 2.4 Linux kernel. Right now I'm porting it to VMWare. When creating the partitions, either on first boot or when the user formats the drive (the user never formats the drive themselves, they use a special command in our OS that takes care of all the system calls for them), it gives the followin...

subexpressions evaluation order

I've looked at SO/IEC 9899:201x under J.1 Unspecified behavior: "The order in which subexpressions are evaluated and the order in which side effects take place, except as specified for the function-call (), &&, ||, ?:, and comma operators (6.5)." Does this means that in func1() + func2(); func2() may be preformed before func1(), o...

how to store printf into a variable?

I want to store a formatted string using something similar to what printf does in C. char *tmp = (char *)sqlite3_column_text(selectstmt, 2); const char *sqlAnswers = printf("select key from answer WHERE key = %s LIMIT 5;", tmp); The following is an error obviously, I am sure alot of c programmers out there would give me a quick answer...

Using C, convert a dynamically-allocated int array to a comma-separated string as cleanly as possible

I’m much less experienced in C than I am in higher-level languages. At Cisco, we use C, and I sometimes run into something that would be easy to do in Java or Python, but very difficult to do in C. Now is one of those times. I have a dynamically-allocated array of unsigned integers which I need to convert to a comma-separated string for...

Load multiple copies of a shared library

I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has global datastructures). For performance reasons, I do not want to simply wrap the function calls in a mutex. What I would like to do is to spawn, say 4 threads, and also...

Debug recursive thread call in C

I have been trying to debug my code whenever I had free-time for the past day and a half and I don't know what is wrong with my code. When I add the close() function to a recursive call, the program gives me an invalid pointer. But when I remove the close() function call the program runs fine, except it does not do what it is supposed to...

Getting started with autotools

Anyone recommend how a person could get started with autotools in building a C project? ...

How to IPC between PHP clients and a C Daemon Server?

Hi all, and thanks for taking a look at the question. The background I have several machines that continuously spawn multiple (up to 300) PHP console scripts in a very short time frame. These scripts run quickly (less than a second) and then exit. All of these scripts need read only access to a large trie structure which would be very e...

opening a file with fopen

I've been trying to open a file and output text, but I keep getting errors. So I thought I would start at the very beginning and just try opening the file. This is my code: #include <stdio.h> #include <stdlib.h> #define CORRECT_PARAMETERS 3 int main(void) { FILE *file; file = fopen("TestFile1.txt", "r"); if (file == NULL)...

Fopen failing for binary file

I have a huge binary file which is 2148181087 bytes (> 2gb) I am trying to do fopen (file, "r") and it failed with Can not open: xyz file (Value too large to be stored in data type) I read on the man page EOVERFLOW error is received when the file size > 2gb. The weird thing is, I use a different input file which is also "almo...

Waiting until a file is available for reading with Win32

I'm watching a directory by calling ReadDirectoryChangesW synchronously. When a new file is available, I try to access it immediately with CreateFile with GENERIC_READ and FILE_SHARE_READ, but this gives me ERROR_SHARING_VIOLATION. The process that put the file in the watched directory does not finish writing by the time I try to read it...