c

c make file compilation error

Syntax error at line 72, column 26, file /usr/include/gconv.h: Error at line 72, column 26 in file /usr/include/gconv.h unsigned char **, size_t *, int, int); .........................1 PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following : ... auto, char, const, double, enum, float, int, long, ulong_varchar,...

How do I address warnings when compiling SQLite with VC++?

Whenever I compile SQLite with Visual C++ 9 I get hundreds of warnings, such as potentially uninitialized variables conversion from wider integer types to narrower integer types signed/unsigned integers mismatches. I'm not alone - there's an SQLite FAQ question specifically about that. The answer to that question says that those wa...

Why would somebody use an if 1 c preprocessor directive

I am looking through some C source code and I don't understand the following part #if 1 typedef unsigned short PronId; /* uniquely identifies (word,pron) pair, i.e. homophones have different Ids */ typedef unsigned short LMId; #define LM_NGRAM_INT #else typedef unsigned int LMId; typedef u...

can we use a pointer freed earlier?

Hi, I have a question regarding free() in C. Suppose I have a pointer to some struct (say node *ptr).. after freeing it can i Initialize it to NULL and make it point to some new location using malloc() or realloc()? For Example: node *ptr=NULL; ptr=realloc(ptr,sizeof(node)); //works exactly like malloc /* Do some operations on ptr */...

How to write a userspace linux block device driver?

Hello, I would like to write a linux block device driver. The driver would not need to access the hardware so it can be in userspace. To start, I have tried to build an example block device driver with this Makefile: obj-m = sbd.o KVERSION = $(shell pwd) PWD = $(shell pwd) all: make -C /lib/modules/$(KVERSION)/build M=$(PWD) modu...

Make an executable at runtime

Ok, so I was wondering how one would go about creating a program, that creates a second program(Like how most compression programs can create self extracting self excutables, but that's not what I need). Say I have 2 programs. Each one containing a class. The one program I would use to modify and fill the class with data. The second fil...

C Are string literals created on the stack?

I'm a little bit confused about this expression: char *s = "abc"; Does the string literal get created on the stack? I know that this expression char *s = (char *)malloc(10 * sizeof(char)); allocates memory on the heap and this expression char s[] = "abc"; allocates memory on the stack, but I'm totally unsure what the first exp...

Svcutil generates duplicate fields for C# proxy class

Hi All, I have 2 simple classes on the web-service side (Java webservice): class A implements Serializable { protected int foo; public getFoo(){..}; public setFoo(){..} } public class B extends A implements Serializable {...} The point is that on client side SvcUtil generates a proxy C# class ProxyB inherited from ProxyA, it's OK...

Can I measure the necessary buffer for sprintf in Microsoft C++?

I'm writing a small proof-of-concept console program with Visual Studio 2008 and I wanted it to output colored text for readability. For ease of coding I also wanted to make a quick printf-replacement, something where I could write like this: MyPrintf(L"Some text \1[bright red]goes here\1[default]. %d", 21); This will be useful becaus...

No O_BINARY and O_TEXT flags in Linux?

When using system-level IO in Linux, I noticed that the compiler recognized the O_RDONLY and O_RDWR flags, but it had no clue whatsoever as to the meaning of the O_BINARY and O_TEXT flags. Is this a Linux thing? ...

stat.h unavailable in Linux?

When I do #include <stat.h> in Linux, I get a compiler error. I need this library for the S_IWRITE flag, which in its turn is used in the context of system-level IO. Is stat.h unavailable in Linux? ...

Why are threads called as light weight processes

Thread is "lightweight" because most of the overhead has already been accomplished through the creation of its process. I found this in one of the tutorial. Can somebody eloberate what it exactly means? ...

Extending mouse click event - C

Currently I am detecting the x and y position of a mouse click, storing it in a Point and displaying it through the message box. I want to be able to read if another keyboard key is being held down such as the Shift or Control button. Looking on MSDN I found the following information: wParam Indicates whether various virtual keys...

Compiling a PHP extention library on Ubuntu (Karmic Koala)

I compiled some PHP extention libs (in C/C++) a while back, on my XP platform. I have now moved the sources to my Ubuntu box, and want to build the libs for use on my Linux box. However, I have come accross a number of obstacles: I cant locate phpize (even after installing the php5dev package) I cant find ext_skel to generate the skel...

What cscope reference card do you use?

What is the standard/best reference card for cscope shortcuts/usage that I can print for quick reference? ...

Is the following program a strictly-conforming C99 program?

The title nearly says it all, but I will restate the question... Is the following program a "strictly conforming program" under the C99 standard? #include <stdlib.h> /* Removing any pre-existing macro definition, in case one should exist in the implementation. * Seems to be allowed under 7.1.3 para 3, as malloc does not begin with _X ...

How can I convert a float/double to ASCII without using sprintf or ftoa in C?

I am using an embedded system. ...

Cast the return value of a function that returns a floating point type

Hi, I have difficulty understanding the article Cast the return value of a function that returns a floating point type (1) In Conversion as if by assignment to the type of the function is required if the return expression has a different type than the function, but not if the return expression has a wider value only because of wid...

How do I declare an external char pointer?

File 1: static char* const path; //GLOBAL int main() { path = FunctionReturningPath(); UsePath() } File 2: extern char* const path; //GLOBAL from file 1 UsePath() //function using global { something = path; } (Pseudo) Would like to use path in file 2. I'm defining the global within main in file 1, is that bad practice u...

Buffer growth strategy

I have a generic growing buffer indended to accumulate "random" string pieces and then fetch the result. Code to handle that buffer is written in plain C. Pseudocode API: void write(buffer_t * buf, const unsigned char * bytes, size_t len);/* appends */ const unsigned char * buffer(buffer_t * buf);/* returns accumulated data */ I'm th...