c

Is there any tutorial on compiling C lib with Pure MSIL Common Language Runtime Support (/clr:pure) with VS? (VS10)

Is there any tutorial on compiling C lib with Pure MSIL Common Language Runtime Support (/clr:pure) with VS? (VS10) (eg x264 lib) ...

Duplicating file handles between processes error

A DLL has the following shared variables (I'm using MinGW): int iCount __attribute__((section(".str"), shared)) = 0; HANDLE hMainFile __attribute__((section(".shr"), shared)) = NULL; HANDLE hProcess __attribute__((section(".shr"), shared)) = NULL; and the global variable: HANDLE hFile = NULL; This is how I'm handling my DLL_PROCESS...

How are controls put in the caption bar?

I noticed Firefox 4, Opera and Chrome, and IE 7/8 put buttons and controls in the title/caption bar, how is this done? Thanks http://img199.imageshack.us/img199/3307/slayerf.png ...

Forgin/Buiilding TCP packets in ANSI C

How do I, without using third-party tools, craft TCP (and even UDP for that matter) packets in ANSI C? I want to be able to set all option flags, source ip address etc. So full control. Haven't found any good text about it online. Or I'm just using the wrong search criteria. ...

doubt regarding operations on "int" flavors

Hi, I am having following doubt regarding "int" flavors (unsigned int, long int, long long int). When we do some operations(* , /, + , -) between int and its flavors (lets say long int) in 32bit system and 64bit system is the implicit typecast happen for "int" for example :- int x ; long long int y = 2000; x = y ; (Higher is assigne...

using functions in dll, in java

Hi, I have some dll files(not custom and not written by me) and I need to use the functions, that are c/c++ written, in these files in my java project. I googled and read many examples about JNI but they were all about writing your own program and dll and then reaching them. Also I don't think dllexport exists in these dlls, so dllimport...

why doesnt this segfault

hello all I stumbled across something "interesting" and I cant put my finger why the behaviour isn't coherent. Check this code. char buf[100]; sprint(buf,"%s",bla); Simple, right. It's easy to understand what is going on when bla is a NULL pointer. This should always segfault right!? In one machine the executable segfaults, on ano...

capture a call stack and have it execute in a different thread.

I need to write a logging api which does the actual logging on a seperate thread. i.e. I have an application which wants to log some information. It calls my API and the api captures all the arguments etc and then hands that off to a seperate thread to be logged. The logger api accepts variadic arguments and therefore my initial though...

How can we use any C library inside our C++ code ?

How can we use any C library inside our C++ code? (Can we? Any tuts on that?) (I use VS10 and now talking about libs such as x264 and OpenCV) ...

What will print out?

What will print out? main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf(“%sn”,p2); } ...

float overflow?

The following code seems to always generate wrong result. I have tested it on gcc and windows visual studio. Is it because of float overflow or something else? Thanks in advance:) #include <stdio.h> #define N 51200000 int main() { float f = 0.0f; for(int i = 0; i < N; i++) f += 1.0f; fprintf(stdout, "%f\n", f); return 0; } ...

A way How to Compile C library into .Net dll ?

Can we compile C library as .Net dll (containing and opening access to all C libs functions) by just compiling cpp project containing code like extern "C" { #include <library.h> } with /clr:pure argument with VS? (VS10) Or we should do something more trickey? ...

[pointer] What does the expression "BIO *client = (BIO *)arg" mean?

Hi experts, Here is the context of the code: void THREAD_CC server_thread(void *arg) { BIO *client = (BIO *)arg; ... } Does the expression (BIO *)arg transform the void pointer arg into a pointer that points to BIO? I'm not sure if I got this right or not. Any help would be much appreciated! Z.Zen ...

Can gdb automatically attach a process on a SIGSEGV

Hi, I have a faulty program that when execute receive a SIGSEGV. I can use gdb like this: $ gdb ./prog But I would prefer that gdb catch the SIGSEGV from prog and attach it automatically. $ ./prog Segmentation Fault (gdb) ... Is there a way to do that? Thanks ...

Are static const variables thread-safe?

Hi all, I'm wondering whether static constant variables are thread-safe or not? Example code snippet: void foo(int n) { static const char *a[] = {"foo","bar","egg","spam"}; if( ... ) { ... } } ...

Reentrant library design in C

Let's say I'm building a library to spork quuxes in C. Quuxes need two state variables to be sporked successfully: static int quux_state; static char* quux_address; /* function to spork quuxes found in a file, reads a line from the file each time it's called. */ void spork_quux(FILE*); If I store that data as global variables, o...

Not null terminated string false alarm?

Klocwork is producing an alarm which seems to be a false one. The bug it mentions describes about 80% of the total bugs in our code. Please advise, Hereby is a snip set (paraphrase):- //a snip set // no bug here // { char* destStr; destStr = (char*)malloc(150); if (destStr != NULL) { destStr[0]= '\0'; //__here is the ...

C but not to C that is the question

I started programming in Java and then eventually moved to C++. I then noticed that many languages use bindings to C libraries such as GTK, OpenGL, OpenAL, and many others. Also languages such as Java, Python, ADA are plentiful in bindings to C libraries... Then there is databases that have bindings to C. I then read an article from Joe...

Session management via pure CGI

I'm currently in the process of writing a little blog / generic posting system using CGI in C as a hobby project and am now in the need of a session management system to authentificate authorized users for posting, editing and similar operations over multiple CGI programs From working with PHP years ago I remember using the superglobal ...

Pointer subtraction confusion

When we subtract a pointer from another the diffrence is not equal to how many bytes they are apart but equal to how many integers(if pointing to integers) they are apart.Why so? ...