c

Why does the -export-dynamic flag not apply to archives?

If I compile and link an executable with the -export-dynamic flag, it doesn't apply to symbols stored in archives that are linked. The flag only on exports symbols for objects that are linked that aren't in archives. Can someone explain why this would be? ...

C header file with bitmapped fonts

Hi, I need to do some rudimentary text rendering to a pixel buffer, and I think that having a table indexed by char with the representation of the letters as a binary array would be more than enough... Anybody knows about a free header as such? Example: char data[256][8][8]; void init() { data['a'] = { {0,0,1,1,1,0,0,0}, {0,1...

how can I fix the MSVC 2005 error: unresolved external symbol __environ

Hi, In my application, I need direct access to the _environ variable because I must have something like the glibc unsetenv (you cannot have that with setenv or putenv). This is the code I need to use: ////////////////////// // unsetenv for WIN32, taken from libc source int unsetenv(const char *name) { size_t len; char **ep; if ...

How do I wrap CFtpFileFind example, in C++?

Trying to wrap this short example in C++. (and its been a while since I did this). int main(int argc, char* argv[]) { //Objects CFtpConnection* pConnect = NULL; //A pointer to a CFtpConnection object ftpClient UploadExe; //ftpClient object pConnect = UploadExe.Connect(); UploadExe.GetFiles(pConnect); ...

[GTK+] Change progress bar with circular wait image

Hi, Is it possible to skin the GTK+ progress bar widget such that it shows a custom image (an AJAX style animated gif maybe)? If so how and if not, is there any other option/control which can achieve this effect? ...

How does getaddrinfo() do DNS lookup?

getaddrinfo() is a function we need to use before creating a socket() or connect()ing, right? Then how does getaddrinfo communicate with DNS server in the first place? PS: Where can I see the complete source of getaddrinfo? ...

c99/c89 standards vs. c coding practice

What code have you written in c that is not defined by either c89 or c99 standards? Specifically, I am looking for techniques like using pointer manipulation to move within a struct instead of using the member operator. This works fine on most compilers, but the compiler is free to add buffer space between struct members, so will not a...

Tool to Scan Code Comments, and convert to Standard Format

I'm working on a C project that has seen many different authors and many different documentation styles. I'm a big fan of doyxgen and other documentation generations tools, and I would like to migrate this project to use one of these systems. Is anybody aware of a tool that can scan source code comments for keywords like "Description",...

C fork dealing with global variable!

Im not understanding the output of this program: #include <pthread.h> #include <stdio.h> #include <unistd.h> int i = 0; int main() { while(i<3) { fork(); printf("%d\n",i); ++i; } } The output is: 0 1 2 2 1 2 0 1 2 2 2 1 2 2 Can please someone tell me how i should tackle this issue in order to fu...

How do I get specific error information from GetFile()?

void GetFtpFile(LPCTSTR pszServerName, LPCTSTR pszRemoteFile, LPCTSTR pszLocalFile) { CInternetSession session(_T("My FTP Session")); CFtpConnection* pConn = NULL; pConn = session.GetFtpConnection(pszServerName); //get the file if (!pConn->GetFile(pszRemoteFile, pszLocalFile)) { //display an error } delete ...

Freeing CUDA memory painfully slow

I am allocating some float arrays (pretty large, ie 9,000,000 elements) on the GPU using cudaMalloc((void**)&(storage->data), size * sizeof(float)). In the end of my program, I free this memory using cudaFree(storage->data);. The problem is that the first deallocation is really slow, around 10 seconds, whereas the others are nearly inst...

Why is FormatMessage() failing to find a message for WinINet errors?

I'm running this to test FormatMessage: LPVOID lpMsgBuf; errCode=12163; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM , 0, errCode, 0, (LPTSTR) &lpMsgBuf, 0, NULL ); However, when it returns lpMsgBuf contains NULL... I was expecting something like ERROR_INTERNET_DISCONNECTED....

Compiler error using "if" statements in C

I am trying to write a very simple application that allows me to enter a number which will allocate a particular grade. I've not used the C language very much as i primarily use C# however i still don't seem to be able to get around the errors: They are all syntax errors, ranging from "if" to "{" although i'm sure everything is as it s...

Need some help understanding pointers and memory in C

I'm writing a bit of code for a class, but since I have no experience in C I'm a bit unsure of what the code I've written actually does. Particularly what the memory looks like. Here's the relevant bits: typedef struct listnode *Node; typedef struct listnode { void *data; Node next; Node previous; } Listnode; typedef struct...

Linkage in C: does GCC follow the C99 spec, or do I not understand the spec?

I'm trying to understand the exact behavior of storage class specifiers in C99, and some GCC behavior seems not to follow the spec, unless I misunderstand the spec. From 6.2.2 (2): Within one translation unit, each declaration of an identifier with internal linkage denotes the same object or function. However, I tested GCC (powerp...

C: Using a select call, when I am reading, how do I keep track of the data?

First of all, I've never worked with C before (mostly Java which is the reason you'll find me write some naive C code). I am writing a simple command interpreter in C. I have something like this: //Initialization code if (select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1) { perror("Select dead"); exit(EXIT_FAILURE); } .... .....

Free static checker for HiTech/Microchip C?

I'm writing a lot of code for the HiTech C compiler. I'm sure that my code would benefit from a static checker like splint, but splint itself trips up on some of HiTech's extensions, like cp0 and sfr declarations. I can't just tell splint to skip the HiTech headers, though, because then it has no idea where most of my identifiers are fro...

are these msec<->timeval functions correct?

I have a bug in this program, and I keep coming back to these two functions, but they look right to me. Anything wrong here? long visual_time_get_msec(VisTime *time_) { visual_log_return_val_if_fail(time_ != NULL, 0); return time_->tv_sec * 1000 + time_->tv_usec / 1000; } int visual_time_set_from_msec(VisTime *time_, long mse...

Creating function-like macros

Hello, gcc 4.4.2 c89 I have this code snippet that I have to repeat in a lot of my code. I am just wondering is there a way to make it short by using a macro function? There is the code I would like to change. ERR_INFO error_info; /* create error object */ ErrorInfo(&error_info); /* pass the address for it to be filled with error in...

Is there a way to make an arbitary fuction timeout, in C?

I have a function that runs in C. I would like for it to timeout, or at least be non blocking. Is there a way to do that without running it as a thread? ...