c

[C] Variable declaration in a header file.

In case I have a variable that may be used in several sources - is it a good practice to declare it in a header? or is it better to declare it in a .c file and use extern in other files? ...

Extern Function???

Simple1.c ------------------------------------ #include"stdio.h" int f1(int x, int y) { printf("%d %d", x, y); return x+y; } ----------------------------------- Simple2.c ------------------------------------ #include"stdio.h" extern int f1(int x,int y); void main() { printf(" %d\n", f1(5,6)); } ----------------------------------- I w...

How to update all C/C++ identifier names in a project

After frequently coming across recommendation not to use leading and double underscores in C/C++ identifiers I decided to fix all our sources once and for all. What I need to do now is convert _Identifier to Identifier_. Should I use a specialized tool for this task of regular expressions will do for this job? In latter case what is the...

Printing name and value of a define

Hello, I have a C program with a lot of optimizations that can be enabled or disabled with #defines. When I run my program, I would like to know what macros has been defined at compile time. So I am trying to write a macro function to print the actual value of a macro. Something like this : SHOW_DEFINE(X){\ if( IS_DEFINED(X) )\ ...

How to use gtk_widget_add_accelerator ?

I am trying to build a gtk widget which will exists when Escape key is pressed. Here is my code. gtk_signal_connect (GTK_OBJECT(window), "delete-event", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); /* FIXME */ GtkAccelGroup *accels = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(window), accels); gtk_widget_...

Enable to call C dll in VB.net Code

Hi, I am running into a problem which I am using C Dll into my VB.net code. I have .H file which shows implementation of this DLL in C language. This .H file contains many structures and unions that contain variable of some structures type. There is a main structure which contains the pointers to these structures and unions and finally a...

Double pointer doubts in C

I have written a program in which in the main function I declare an array of pointers and then I call a function which splits a given sentence and then want to assign it to the array of pointers in main(). I am unable to do. Can you please check the code pasted below: int main(void) { char *data[3]; allocate(data); ...

implementation of rand()

I am writing some embedded code in C and need to use the rand() function. Unfortunately, rand() is not supported in the library for the controller. I need a simple implementation that is fast, but more importantly has little space overhead, that produces relatively high-quality random numbers. Does anyone know which algorithm to use or s...

C char array is not a string pattern?

Hello, I am having a compilation error on the following code: printf((char *) buffer); and the error message that I am getting is: cc1: format not a string literal and no format arguments... I suspect there are some libraries that I forgot to install, as I was able to compile and run the code without an error on the other machine......

[C] Header per source file.

I'm trying to understand the purpose behind one header per each source file method. As I see it, headers are meant for sharing function declarations, typedef's and macro's between several files that utilize them. When you make a header file for your .c file it has the disadvantage that each time you want to see a function declaration or ...

OpenCV Video capture and fps problem

Hi to all, I'm capturing video from my webcam using OpenCV on MacOSX. It works fine but when I try to play on QuickTime my captured video it plays too fast. i.e. I capture from camera for 10 seconds but when I play on QuickTime the video is 2 seconds. I've tried to change fps from 25 to 10 and It's works quite fine, but I'm sure it's ...

Different access levels with PAM

Currently I have a graphical application that has two levels of access, operator and administrator. The login and authentication is all homebrewed and I'd like to switch the application to use PAM instead. I'm not sure what the right way to do that is. Correct me if I'm wrong, but it seems that PAM boils down to a "yes" or "no" check--y...

Guides for implementing a foreign function interface

Right now I'm working on a scripting language that doesn't yet have a FFI. I'd like to know what's the most convenient way to get it in, assuming that I'd like to write it like cool geeks do - I'd like to write the FFI in the scripting language itself. The programming language I need to interface is C. So for basics I know that libdl.so...

TextWriter.ReadToEnd vs. Unix wc Command

Hello. Another question re. Unicode, terminals and now C# and wc. If I write this simple piece of code int i=0; foreach(char c in Console.In.ReadToEnd()) { if(c!='\n') i++; } Console.WriteLine("{0}", i); and input it only the character "€" (3 bytes in utf-8), wc returns 3 characters (maybe using wint_t, though I haven't...

How to interpret "error C2018: unknown character '0x40'?

While compiling some code I receive the following: "error C2018: unknown character '0x40'" I wonder how to resolve such issue? ...

Similar function to GetLastError in objective-C/C?

I'm doing some lovely socket programming in objective-C right now and part of my code is giving me an error (in the setsockopt method call). I was wondering if anyone knows of a similar function to the GetLastError() function in C++ that I could use in objective-C to determine the problem with my code? ...

How to resolve "LINK : fatal error LNK1561: entry point must be defined"?

Guys/gals: How can I resolve the following linking error: "LINK : fatal error LNK1561: entry point must be defined". What I was trying to do is simply recompiling MySQL Storage engine example with Visual Studio 2008. ...

On Solaris Sparc 64bit, Can a 64bit process load a 32 bit shared library

On a 64bit Solaris Sparc system, can an Apache Server built in 64bit mode load a 32 bit plug-in? ...

Displaying standard error messages

Hello, I am just testing a small program that I want to test. I am wondering if there is a way to use the stderr to display what the actual error was. For example, if the file doesn't exist. Is there a standard error that I can display. I am using stderr, and I thought by using that, I could display what the actual error was. For e...

NTLM authentication for a web server side application

My Windows based application written in C++ ( basically an HTTP/1.1 proxy server) listens for requests from various users. Presently it is able to send a 407 Basic Challenge, and process the response from the Headers. I know I must modify the challenge headers, so that the client browsers make an NTLM based response for the purpose of au...