c

Can I set Visual Stdio 2005 to ignore assertions in a specific region of code while debugging....

Aaargh! OK, here's the scenario. I'm debugging my own app (C/C++) which is using some library developed by another team in the company. An assertion fails when my code generates some edge case. Its a pain because the assertion is not formulated correctly so the library function is working OK but I get all these interruptions where I jus...

Load Paths and Ruby C-Extensions

How do you allow a C-extension to use rb_f_require to require a file from outside the ext directory (e.g. requiring lib/foo/foo.rb from ext/foo.so). ...

Constant array types in C, flaw in standard?

Paragraph 6.7.3.8 of the C99 spec states If the specification of an array type includes any type qualifiers, the element type is so-qualified, not the array type. If the specification of a function type includes any type qualifiers, the behavior is undefined. In the rationale (logical page 87, physical page 94), an example of casting a flat...

Erasing a Char[]

Okay i am working on someone elses code. They do alot of this: char description[256]; description[0]=0; I know this would put a \0 in the first spot of the character array. But is this even a safe way to erase a string? Also visual studio keeps reporting memory leaks, and i've pretty much tied this done to the strings that are used. ...

Container Class / Library for C

Does anyone know of any C container libraries? I am looking for something which gives standard implementations of linked lists, arrays, hash tables etc, much in the same way as the C++ STL does. Key concerns are: Client code should be able to create containers for multiple different data types without modifying the library. The interfa...

Using far function pointers

I realize that far is compiler specific, but my expectation is that the placement of the far specifier should make sense to those who really understand pointers. So, I have two applications that share the processor's entire memory space. App A needs to call function foo that exists in app B. I know the memory location of function foo....

Lightweight regex parser

I'd like to use a Regex parser to aid in some string processing in a C application. I'm ideally looking for something lightweight and open-source. The target platform is an embedded system so we're looking to save as much as possible with memory consumption in particular. I've found a number of options online but was wondering if anyone ...

Simplest Way To Open and Use a Socket in C

I'm just starting out doing some basic network programming with C, and I found all these things about sockets and they all seem very convoluted. Maybe opening sockets with C is just convoluted itself, but I would like to know the simplest and most effective way to open and write data to a socket in the C programming language. Thanks ...

Algorithm: Keeping count of key/value pair in NSDictionary

Being new to Cocoa, and probably not knowing all of the potential classes available that already have this functionality neatly wrapped in an OO class, here's an algorithm inquiry. What's the best bet to count how many times a particular key occurs in an array of multiple NSDictionary instances? Essentially my data structure (in this ca...

VS2008 Missing C/C++ Header Files

So, I'm working on some network programming in C, and it would seem that I am missing a bunch of standard C/C++ header files. For example, sys/socket.h is not there. A few otheres are missing too like netdb.h, and unistd.h. Is there a pack I need to install to get these on windows? Thanks ...

Complex builds in Visual Studio

I have a few things that I cannot find a good way to perform in Visual Studio: Pre-build step invokes a code generator that generates some source files which are later compiled. This can be solved to a limited extent by adding blank files to the project (which are later replaced with real generated files), but it does not work if I don...

vim keyword completion

How do i tell vim editor about my include files path, so that it can auto complete the function names when i press control+N. For example, I have c program like below #include<stdio.h> int main() { sca //here i press control+N, it doesnot complete to scanf } ...

How to have read permission in a recent created folder and file in C?

Hi, I've created a a folder and after I open a file inside of that folder a write on it. It happens that after that I try to open the file but I have no permissions thus I have to change it manually. /* str1 has tha name of the folder */ /* str the bytes I want to write in the file inside the folder*/ ... mkdir(str1,0777); if...

C String Concatenation

I'm working in C and I have to concatenate a few things. Right now I have this: message = strcat("TEXT " + var); message2 = strcat(strcat("TEXT ", foo), strcat(" TEXT ", bar)); Now if you have experience in C I'm sure you realize that this gives you a Segmentation Fault when you try to run it. So how do i work around that? ...

Segmentation Fault (C)

I'm getting a segmentation fault in the following C code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #define PORT 6667 #define MAXDATASIZE 1024 int bot_connect(char *h...

What is a good open source message bus for embedded Linux?

I'm looking for a good open source message bus that is suitable for embedded Linux devices (Linux and uClinux). It needs to satisfy the following criteria: Must be free software and LGPL or a more liberal license due to uClinux only supporting static linking Must have a C API Must have a relatively small footprint and not depend on th...

cfront for C++

Is a cfront tool available for the new C++? For any other modern languages? ...

Output single character in C

When printing a single character in a C program, must I use "%1s" in the format string? Can I use something like "%c"? ...

Can I make GCC warn on passing too-wide types to functions?

Following is some obviously-defective code for which I think the compiler should emit a diagnostic. But neither gcc nor g++ does, even with all the warnings options I could think of: -pedantic -Wall -Wextra #include <stdio.h> short f(short x) { return x; } int main() { long x = 0x10000007; /* bigger than short */ printf...

How to add one day to a time obtained from time()

I have a time represented as the number of seconds elapsed since midnight, January 1, 1970, UTC (the results of an earlier call to time()). How do I add one day to this time? Adding 24 * 60 * 60 works in most cases, but fails if the daylight saving time comes on or off in between. In other words, I mostly want to add 24 hours, but somet...