c

How can I hide the DOS Window and bring up a splash screen?

Ive used the Matlab Compiler to create a .exe file.. The program takes 15 sec to start.. So I figured that I needed to get rid of the DOS window and needed a splash screen.. How can I do that?? ...

How to know if a process had been started but crashed in Linux

Consider the following situation: - I am using Linux. I have doubt that my application has crashed. I had not enabled core dump. There is no information in the log. How can I be sure that, after the system restart my app was started, but now it is not running, because it has crashed. My app is configured as a service, written in C/C++....

Moving data from inline assembly into array in C

Hi I have a very simple problem; I have an array which should store me the results of some inline assembler routine. The question that I have is now how can I move the data from the inline assembler into the array? I am using gcc for compiling on an x86 machine. Consider the following simple code fragement: int main() { int resul...

Why is this compilation error coming?

Hello, I faced one issue while working on a C code with Microsoft Visual Studio-2005 compiler. I tried to declare a big buffer statically as : int gbl_data[4096*4096*256]; EDIT: This declaration was a global variable in a header file. It was giving an compilation error saying – “cannot allocate an array of constant size 0”. Means...

Understanding kernel assigned local addresses on a udp socket

Hi! i'm developing a java application using the jstun library (hxxp://jstun.javawi.de/), and i need to compare my public ip with the one chosen by the kernel (wildcard address - hxxp://java.sun.com/j2se/1.5.0/docs/api/java/net/DatagramSocket.html#DatagramSocket() ) when i create a udp socket. what i don't understand is, if my local ip ...

C: Recommended style for dynamically sized structs

I need to transfer packets through the internet whose length should be dynamic. struct packet { int id; int filename_len; char filename[]; }; The problem is that zero-length arrays are not ISO-compliant. Should I use char filename[1]; instead? But then sizeof(struct packet) will not return the correct value anymore. ...

How to debug JNI/C library?

Hi, We have system here that uses Java JNI to call a function in a C library. Everything running on Solaris. I have a problem somewhere with string encoding. An arabic character is returned by the function written in C, but the JNI methods receives a string with another encoding. I already tried setting $NLS_LANG, and the vm parameter ...

memory-mapped files in C

Hi, I was playing around with memory-mapped files in C and was wondering if there is a way to replace the FILE * from fopen with a memory mapped file transparently. Example: FILE * fp = g_fopen(...); //Program does things to this fp. fclose(); But instead, is it possible to have FILE *fp = my_fopen(...) Where my own function would...

Freeing memory returned from C functions.

In C, which is the better practice when it comes to freeing memory returned from functions: Provide a "destructor" function that encapsulates the call to free(). Require users to free() the returned pointer themselves. For example, to open and close a file we do: FILE* f = fopen("blah", "w"); fclose(f); Is this preferable to: FIL...

select(), recv() and EWOULDBLOCK on non-blocking sockets

Hi folks, I would like to know if the following scenario is real?! select() (RD) on non-blocking TCP socket says that the socket is ready following recv() would return EWOULDBLOCK despite the call to select() ...

How could this C fragment be written more safely?

Hi, I have the following C code fragment and have to identify the error and suggest a way of writing it more safely: char somestring[] = "Send money!\n"; char *copy; copy = (char *) malloc(strlen(somestring)); strcpy(copy, somestring); printf(copy); So the error is that strlen ignores the trailing '\0' of a string and therefore it ...

What is faster (x < 0) or (x == -1)?

Variable x is int with possible values: -1, 0, 1, 2, 3. Which expression will be faster (in CPU ticks): 1. (x < 0) 2. (x == -1) Language: C/C++, but I suppose all other languages will have the same. P.S. I personally think that answer is (x < 0). More widely for gurus: what if x from -1 to 2^30? ...

How to find size of static allocations from binary?

Is it possible to determine the total amount of memory dedicated to static and global variables from the binary? I'm looking for a Linux utility that reads an elf file and figures out how much memory is pre-allocated for variables. ...

Eclipse cross-compile... how can I do that?

Hi, I am developing on a Windows machine using Eclipse in C code. All the files are physically located on a Linux server. I am using Eclipse only for editing and code browsing. When I want to compile, I open a terminal and telnet to the Linux server from which I call a file that sets up few variables and eventually invoke a "make" comm...

Preproccessor ignore

I am migrating from Visual Studio 6 to Visual Studio 2008 and I have a function of a component I am using named SetDefaultPrinter. Unfortunately there is a windows library function now, SetDefaultPrinter, with the same name. And the macro associated with it is getting in the way of me using my function. This is my workaround I have to ...

Where does _CrtDbgReportW ouput in Windows Mobile?

I am using ASSERTE macro to check for pre-conditions. According to its definition it is using ASSERT_BASE, which in turn calls _CrtDbgReportW to print out the message. Where does _CrtDbgReportW output goes to? I would assume that if the application is started from debugger, it would go to debugger window. Where would the messages go if ...

UML representation for tasks

I am in the process of designing system with a many tasks and a lot of inter-task messages. The system will be basically developed in C. In my design I am trying to use UML representation to show the messages that are passed between tasks. But it is becoming difficult to represent things like decision making etc. Are their any predefi...

RDTSC in C inline assembly causes segmentation fault!

Hi Thanks to some help of you guys I got my little inline assembler program almost there where I want it to have. However, there now seems to happen something very strange with the rdtsc command; basically, I get a segmentation fault when calling it. int timings[64*N]; int main(void) { int i; __asm__ __volatile__ ( "...

why is char's sign-ness not defined in C?

The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char. And indeed gcc define that accord...

In c, how to make a file descriptor blocking?

Given an arbitrary file descriptor, can I make it blocking if it is non-blocking? If so, how? ...