c

Cross-compile from (open)Solaris to Windows?

Is there any way I can cross-compile C/C++ code for Windows (XP, Vista, Win7), ideally in 64-bit as well as 32-bit (for Vista and Win7), from a Solaris or OpenSolaris setup? My codebase is already cross-platform, I would like to cross-compile it (generate windows DLLs and EXEs) from Solaris or Linux as part of an automated process. I w...

Help on linking in gcc

In Microsoft visual c++ compiler, you can specify linker options using #pragma comment(lib, "MSVCRT") //links with the MVCRT library see this page I find this feature very useful because linker errors are common and i want to just place all the linker options in my source code instead of specifying them to the compiler. question: I...

Benefits of declaring a function as "inline"?

Every time I read about the "inline" declaration in C it is mentioned that it is only a hint to the compiler (i.e. it does not have to obey it). Is there any benefit to adding it then, or should I just rely on the compiler knowing better than me? ...

evaluate trig functions in degrees as opposed to radians

So I have a function in an app that needs to let the user calculate a trig function (sin,cos,tan) using radians OR degrees, and also to expect a returned value from inverse trig functions (asin,acos,atan) as either radians or degrees. is there any way to do this without building in a converter directly into the way they input something?...

do-while stopped working

Back again with another rookie question. While working on a function for my homework project I found that my menu wouldn't exit when I press X, it worked just an hour ago and I haven't changed anything in main(). I commented out all the code in my functions just to be sure that nothing in a function interfered. I just can't find any prob...

How can I create bitmaps (in C)?

I am wondering how I can both import and export bitmaps to and from C. I'm basically lost on where to begin. ...

"tc" "th" files for C program

Hi, I first encountered files ended with .tc and .th in a C library (http://www.vlfeat.org/api/files.html, only .tc files are listed there. To see .th file, one has to download its source code http://www.vlfeat.org/download/vlfeat-0.9.5-bin.tar.gz. They are under vl directory.). Just wonder what do they mean and relation with normal .h ...

sqlite3_open - problems checking if a file is a sqlite3 database

Hey, I'm working with sqlite3 for the first time, and cannot get it to properly check a file before it opens it. So far, sqlite always returns OK on any file. Also, the file name is a variable returned from the GTK file chooser. It returns an absolute path, I'm guessing this is not a problem. Thanks for any help. This is a snippet of...

need base64 encode/decode in c

I need a function to encode base64 and a function to decode base64 string in c. I found http://base64.sourceforge.net/b64.c but the functions work on files, not strings, and add line breaks. I need one that simply encodes/decodes strings. Where can I find such a sourcecode? ...

Multiprocess and Multithreaded design

Parent process preforked a number of process and each preforked process created number of threads (thread pools). All the thread in the same address space can share the data and can use the different synchronization techniques for critical sections. I want to know how to synchronized between threads which are from different address space...

Problems with structures with pointers to arrays of other structures in C

Hi there! I am attempting to tackle college worksheet on C programming (no marking for it, just to improve our learning). What we're meant to do is get a few details about shipping docks. I decided to use structures for this. My code is below, what I need help with is to print out the information (to see if its working) of whats at the...

Something to use for graphing numbers

Is there some sort of application/API with which I can graph sets of numbers(line graph)? I will be interfacing with an external device which will provide me with some readings(via a custom format through a /dev/cua file) at a rate of about 1000 readings per second. I want to be able to graph this as a line graph. So I will need to be...

Multiple Thread Progress Bar Control with gtk

in my C program , download some files from the internet, im using a GTK progress bar to show the download progress. i wanna if i download one file ,my app show one progress bar if i download three files ,my app can show three progress bar. the rest can be done in the same manner. i create UI with glade3. GtkTreeView have 3 colum...

socket return 'No such file or directory"

Hello, Linux GCC 4.4.2 I am doing some socket programming. However, I keep getting this error when I try and assign the sockfd from the socket function. " Socket operation on non-socket" Many thanks for any advice, #if defined(linux) #include <pthread.h> /* Socket specific functions and constants */ #include <sys/types.h> #include...

Flood fill algorithm

Hi, im working in a simple graphical library in C with turbo C++ because im developing a very primitive version of a paint style program, everyting works well but i can´t get the flood fill algorithm to work. Im using the 4 way flood fill algorithm, first i tried with the recursive version but it only work with small areas, filling large...

Should one really set pointers to `NULL` after freeing them?

There seem to be two arguments why one should set a pointer to NULL after freeing them. Avoid crashing when double-freeing pointers. Short: Calling free() a second time, by accident, doesn't crash when it's set to NULL. Almost always this masks a logical bug because there is no reason to call free() a second time. It's safer to let t...

Why include header in the method definition file?

Hi say you have a source file named sum.c that looks like this: #include "sum.h" int sum(int x, int y) { return x+y; } What's the point of including method's header in it's own definition file? Aren't you supposed to include it only in source files that call the sum function? ...

C - Difference between "char var[]" and "char *var" ?

I am expecting that both following vectors have the same representation in RAM: char a_var[] = "XXX\x00"; char *p_var = "XXX"; But strange, a call to a library function of type f(char argument[]) crushs the running application if I call it using f(p_var). But using f(a_var) is Ok! Why? ...

Bind a client's local IP through SSL

Hi, I'm looking to add SSL support to a client application written in C/C++ that I'm developing (it is multi-platform, designed to work on Linux and Windows). OpenSSL documentation is pretty poor, but I found a good working tutorial here. To my knowledge, however, there is no way to bind the socket to a local IP address using the BIO ha...

C99: Can I declare variables in the beginning of a block in a 'for'?

Is the following code legal according to C99? ... for(....) { int x = 4; ... } ... You can assume that before line 3 the variable x was never declared. C99 (PDF) Until now I have only found the following, but I dont think that this is enough: A block allows a set of declarations and statements to be grouped into one syntactic unit...