c

Dynamic Labels in x86 Assembler

Hi And again I ran into a problem where I cant find a straightforward solution... I am doing some inline assembly and I wanna execute some code a few times by using the .rept directive which tells the assembler to act as if the lines following .rept, up to the one just before .endr, are repeated the specified number of times. The obvi...

Merge multiple .so shared libraries

Say I have a.so and b.so. Can I produce c.so as a single shared library with all the functions exported by a and b, of course resolving all intra-dependencies (i.e. all functions of b.so called by a.so and the other way around)? I tried gcc -shared -Wl,soname,c.so -o c.so a.so b.so but it doesn't work. Same goes if I archive a.o and ...

What is your favorite eclipse plugins for c / c++ development?

Besides just the CDT what do you find essential for c development using eclipse? ...

Are there are any platforms where pointers to different types have different sizes?

The C standard allows pointers to different types to have different sizes, e.g. sizeof(char*) != sizeof(int*) is permitted. It does, however, require that if a pointer is converted to a void* and then back to its original type, it must compare as equal to its original value. Therefore, it follows logically that sizeof(void*) >= sizeof(...

master / worker threads and signal handling

I am writing a program, with a master thread and some worker threads, and I would like to get the signal handling right. My problem is the following : Master thread starts and do all allocation Master thread sets a SIGINT signal handler Master threads start worker threads. worker threads don't need special cleanup, however they can b...

Feeding an input stream with EOF

I am building a small shell interpreter which executes various commands, and I accomplish this by forking my process. However, I want the child process to stop waiting for input in the standard input stream, and it does so by expecting an EOF. How do I push an EOF deliberately into that stream? More specifically, if I am looping on thi...

How can I identify my build platform properly?

I want to know a parameter which is an indicator of the current OS. If am supporting Windows and Linux, how can I get a system parameter which differentiates the OS types. This for an OS independent makefile which runs both in Windows and Linux by checking the parameter in an 'if'. ...

Having trouble with fork(), pipe(), dup2() and exec() in C

Here's my code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <wait.h> #include <readline/readline.h> #define NUMPIPES 2 int main(int argc, char *argv[]) { char *bBuffer, *sPtr, *aPtr = NULL, *pipeComms[NUMPIPES], *cmdArgs[10]; int fdPipe[2], pCount, aCount, i, status, lPids[NUMPIPES]; pid_t pid; ...

Getting my ip address

Hey! I have a computer on a small network, so my ip is 192.168.2.100. I am trying to get my real ip. I download the no-ip client but that just seems like a lot of trouble for such a simple thing. I created this php script that got http://www.ip-adress.com/ page and retrieved the ip it gave me. Is there a simpler way? Either using C, ...

How do I work with dynamic multi-dimensional arrays in C?

Does someone know how can I use multi-dimesional arrays using C? Is that possible? Thanks a lot... ...

Java Native Interface with any arbitrary C code

I have a .dll that was provided, and I need to interface with it using java. Do I have to rewrite the C to use the JNI types provided in jni.h? as seen in java sun's jni example. Otherwise, How do i declare the native function my java function to pass and receive pointers? thanks ...

How to find a list of wireless networks (SSID's) in Java, C#, and/or C?

Is there a toolkit/package that is available that I could use to find a list of wireless networks (SSID's) that are available in either Java, C#, or C for Windows XP+? Any sample code would be appreciated. ...

Interesting Scope Problem, Explanation?

I just discovered a bug where the code looked something like this: char *foo = malloc(SOME_NUM * sizeof(char)); if (!processReturnsTrueOrFalse(foo)) { free(foo); char *foo = malloc(SOME_NUM * sizeof(char)); // More stuff, whatever } This compiles, but it's weird that I am allowed to define two variables within the same fun...

What's sizeof(size_t) on 32-bit vs the various 64-bit data models?

On a 64-bit system, sizeof(unsigned long) depends on the data model implemented by the system, for example, it is 4 bytes on LLP64 (Windows), 8 bytes on LP64 (Linux, etc.). What's sizeof(size_t) supposed to be? Does it vary with data model like "long" does? If so, how? [1] en.wikipedia.org/wiki/64-bit#64-bit_data_models ...

Malloc'ing a string

I just converted an Objective-C library to a C library in the hopes of making it cross platform. However, everything appears to do okay until I send this thing off to be processed. It's at the point I get an error. Looking back a few revisions, I noticed something in the debugger. Right after a malloc'd string like so: char *theStri...

character encoding in libc?

What is the character encoding expected in libc? For example, gethostname(char *name, size_t namelen); takes char* as argument. Is it expected that the name parameter be encoded in utf8(which keeps the ascii intact) or plain ascii or some other format? Also does C mandates any character encoding scheme? ...

Help with error message from gcc

Any idea about this error? gcc -oxtmpmain.exe xtmpmain.o fiber_driver.o xtmp_options.o getopt.o D:\usr\xtensa\XtDevToolsDE\in stall\tools\RB-2008.4-win32\XtensaTools\lib\iss\xtmp.lib xtmpmain.o(.text+0x213):xtmpmain.c: undefined reference to `_uart_setup' xtmpmain.o(.text+0x2da):xtmpmain.c: undefined reference to `_uart_cleanup' coll...

Reading / Writing to a socket using a FILE stream in c

I discovered a nice abstraction whereby I can read in data from UDP using a FILE. This works great for reading in data, but I cannot get it to work for spitting out data over UDP. Here is the code for reading in the UDP data over a FILE stream: u_int8 *buf; int sockfd = socket(AF_INET, SOCK_DGRAM, 0); struct sockaddr_in serverAddr; if (...

How to visualize bytes with C/C++

I'm working my way through some C++ training. So far so good, but I need some help reinforcing some of the concepts I am learning. My question is how do I go about visualizing the byte patterns for objects I create. For example, how would I print out the byte pattern for structs, longs, ints etc? I understand it in my head and can under...

Compilation error

Can anybody help me? gcc -o uartsim.exe xtmpmain.o uartsim.o fiber_driver.o xtmp_options.o getopt.o D:\usr\xtensa\XtDevToolsDE\install\tools\RB-2008.4-win32\XtensaTools\lib\iss\xtmp.lib gcc: xtmpmain.o: No such file or directory make: *** [uartsim.exe] Error 1 ...