Click here to Skip to main content
15,942,407 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am running into following error while trying to port an old driver (written in C) from Win2k to Win7 using WDK 7600.163385.1:

code.c(x) : error C2054: expected '(' to follow 'i'

Code snippet:


Based on the information I have found so far, it may be due to missing definition of keywork 'IN', but I do not know where is it defined. Also, the error goes away if I rename .c file to .cpp file but I do not want to do so for 2 reasons:
1. it is a kernel level module for which cpp is unsupported by MS
2. I will need to make additional changes to my code since some other featues are compatible with only C program

I would appreciate any help and guidance.


1 solution

1. IN and OUT are usually define as nothing:

#define IN
#define OUT

(there is no keyword in C that distinguishes input and output parameters).

2. Try adding /P to your compiler command line ("Generate Preprocessed File" option in Visual Studio Properties page under C/C++, Preprocessor".)

That will save the preprocessor output to a separate file which you can then inspect to see what preprocessor definitions are being used.

(I suspect NTSTATUS is somehow defined as 'i' -- that's the most likely way you would get that error message.)

3. There shouldn't be a problem with compiling C code with the C++ compiler and using it for a kernel mode driver. You won't get in trouble using C++ if you are basically just writing C. You might get into trouble if you are using "advanced" features of C++ that aren't C and don't understand how the compiler is implementing those features. But you can cause the same problems using C if you want to (it's just that when you write the same thing in C it looks so complex that you know it's probably bad news.) See:[^]

However, I wouldn't just switch from C to CPP without understanding what the problem is. When problems just magically go away they have a habit of coming back and biting you later...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900