c

C/C++ line number

In the sake of debugging purposes, can I get the line number in C/C++ compilers? (standard way or specific ways for certain compilers) e.g if(!Logical) printf("Not logical value at line number %d \n",LineNumber); // How to get LineNumber without writing it by my hand?(dynamic compilation) Thanks ...

empty struct definitions illegal in C but not C++?

struct t_empty { }; This appears to compile properly in C++ but not C. (at least with the TI 28xx DSP compiler, where it emits the error "expected a declaration") Is this mentioned somewhere in the C standards, or is my compiler broken? ...

what is the win32 alternative to the Unix daemon() subroutine?

I have to call several (> 10) .exe command line programs in the background. Creating a Windows Services doesn't sound very appealling in this context - c'mon, that's a bit overpowered for such a simple task. Is there anything like a daemon(3) subroutine for Windows? ...

Using a class callback for a custom control?

I'm creating a custom control class and since I want complete control of it, I register the class and want to use the class's LRESULT CALLBACK OGLTOOLBAR::ToolProc(HWND, UINT, WPARAM, LPARAM) but it's not letting me. I'm doing: HWND OGLTOOLBAR::create(HWND parent,HINSTANCE hInst, int *toolWidthPtr) { if (toolhWnd != NULL) ...

NetBeans IDE 6.8 not working nicely with cygwin 1.7.5.1

I'm trying to use NetBeans to compile C code and have the following versions from cygwin gcc 3.4.5 g++ 3.4.5 GNU Make 3.81 GNU gdb 6.8.0 Here are the messages from trying to compile the Welcome program /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf make[1]: Entering directory `/cygdrive/c/Users/Milktrader/Docume...

Display problem after deletion in linked list in C

Hi, actually this was another problem but it changed so I decided to open a new question. My code is typedef struct inner_list { int count; char word[100]; inner_list*next; } inner_list; typedef struct outer_list { char word [100]; inner_list * head; int count; outer_list * next; } outer_list; void delnode(outer_list **head,ch...

SDL+OpenGL app: blank screen

I spent the last three days trying to create a small app using SDL + OpenGL. The app itself runs fine -- except it never outputs any graphics; just a black screen. I've condensed it down to a minimal C file, and I'm hoping someone can give me some guidance. I'm running out of ideas. I'm using Windows Vista, MinGW & MSYS. Thanks in adva...

Adding -fno-omit-frame-pointer option in ARMARCH5gnu in VxWorks leads to random crashes.

Application crashes randomly when -fno-omit-frame-pointer option is added during compilation. This problem happens in ARMARCH5gnu architecture in VxWorks. Any pointers in the direction for resolving this will be helpful. ...

C preprocessor problem in Microsoft Visual Studio 2010

I've encountered a problem with the new Visual C++ in VS 2010. I've got a header with the following defines: #define STC(y) #y #define STR(y) STC(\y) #define NNN(y) 0##y #define NUM(y) NNN(y) The intent is that you can have some constant around like #define TOKEN x5A and then you can have the token as a number or as a string: NUM...

How to handle an array of pointers in Objective-C

I figured out the answer to this question, but I couldn't find the solution on here, so posting it for posterity. So, in Objective-C, how do you create an object out of a pointer in order to store it in objective-c collections (NSArray, NSDictionary, NSSet, etc) without reverting to regular C? ...

A simple C XML parser

This is what I need to do: I need to read an XML formatted document and extract from it the elements and their values, for example in the following code: <user name="Mark"> <param name="Age" value="21"/> <param name="Country" value="NL"/> </user> I need to extract: name = Mark, Age = 21 and Country = NL. Up until today i've b...

Real-Time Data Streaming to Multiple Clients

Hi all, I would like to write an application which will stream data at 2400 baud over the internet from a server to multiple clients. The data will be the same for each client, and it would probably be fine to send it as a UDP stream, since exact data accuracy is not a 100% necessity, as there are checksums built-in to the data format a...

Loop through hex variable in C

I have the following code in a project that write's the ascii representation of packet to a unix tty: int written = 0; int start_of_data = 3; //write data to fifo while (length) { if ((written = write(fifo_fd, &packet[start_of_data], length)) == -1) { printf("Error writing to FIFO\n"); } else { ...

using scanf in C/C++

To read an int using scanf we use: scanf("%d",&i); What if i is long not int?? Note: when using %d with long it gives me an irritating warning.. Thanks! ...

What exactly does an #if 0 ..... #endif block do?

In C/C++ What happens to code placed between an #if 0/#endif block? #if 0 //Code goes here #endif Does the code simply get skipped and therefore does not get executed? ...

C/C++ I18N mbstowcs question

I am working on internationalizing the input for a C/C++ application. I have currently hit an issue with converting from a multi-byte string to wide character string. The code needs to be cross platform compatible, so I am using mbstowcs and wcstombs as much as possible. I am currently working on a WIN32 machine and I have set the loc...

InternetReadFile() corrupting downloads in C

I'm able to download text documents (.html, .txt, etc) but I can't download images or exe's. I'm pretty sure that this is because I'm using a char, and those files are binary. I know that in C# I would use a byte. But what data-type would I use in this case? char buffer[1]; DWORD dwRead; FILE * pFile; pFile = fopen(file,...

DirectX 9 HLSL vs. DirectX 10 HLSL: syntax the same?

For the past month or so, I have been busting my behind trying to learn DirectX. So I've been mixing back back and forth between DirectX 9 and 10. One of the major changes I've seen in the two is how to process vectors in the graphics card. One of the drastic changes I notice is how you get the GPU to recognize your structs. In DirectX ...

Serialize struct with pointers to NSData

Hey guys, I need to add some kind of archiving functionality to a Objective-C Trie implementation (NDTrie on github), but I have very little experience with C and it's data structures. struct trieNode { NSUInteger key; NSUInteger count, size; id object; __strong struct trieNode ** children; __strong struct trieN...

[Linux] domain socket "sendto" encounter "errno 111, connection refused"

I am using domain socket to get values from another process, like A to get a value from B, It works well for months. But recently, A is failed during "sendto" message to B with "errno 111, connection refused" occasionally. I checked the B domain socket bind file, it is exists. I also do some tests in another machine, also works well. S...