Redeclaration errors (UCHAR winnt.h(81), windef.h(47))

Started by tpekar, November 19, 2014, 05:53:22 PM

Previous topic - Next topic

tpekar

I am trying to compile a console program supplied by Evisions to allow an API from a C program to call an Argos program.  When I try to compile it with Pelles C, I get the following errors:

Building console.obj.
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(81): error #2119: Redeclaration of 'UCHAR', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(47).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(81): error #2119: Redeclaration of 'PUCHAR', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(48).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(82): error #2119: Redeclaration of 'USHORT', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(45).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(82): error #2119: Redeclaration of 'PUSHORT', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(46).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(83): error #2119: Redeclaration of 'ULONG', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(43).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(83): error #2119: Redeclaration of 'PULONG', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(44).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(84): error #2119: Redeclaration of 'PSZ', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(49).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(86): error #2119: Redeclaration of 'LPVOID', previously declared at C:\Users\pekar\Documents\Pelles C Projects\include\windef.h(158).
C:\Users\pekar\Documents\Pelles C Projects\include\winnt.h(2399): fatal error #1014: #error: "undefined processor type".
*** Error code: 1 ***
Done.

Has anyone seen this or a similar problem?  Is there a compiler setting or something that could fix it?  I would include the source but it has over 4000 lines of code.

Thanks in advance for any help!

frankie

This happen when the sequence of include files is not correct (typically when using winsok before windows.h).
Post a short sample reproducing the errors.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

laurro

  I assume you refer to maprapimain.v1.0.1.c,
a link or a name is useful if you ask for help.
Is only 23.2 Kb as a zip file and the limit for
posting is 1 Mb.

enable MS extensions -Ze
define compatibility names -Go

in project\project options\compiler\options
just to be sure.

Laur

tpekar

Yes, Laur, maprapimain.v1.0.1.c is the name of the program.  I had changed

enable MS extensions -Ze
define compatibility names -Go

and still get the errors.  Are you familiar with this program?  If I need to post a .zip, how do I do that?

laurro

No, I'm not and I don't intend to be (familiar).

First problem.
At this point your project is probably a mess.
The compiler flags must be like:

-std:C11 -Tx86-coff -Ot -Ob1 -fp:precise -W1 -Gd -Ze -Go

and for linker:

-subsystem:console -machine:x86 -release kernel32.lib advapi32.lib delayimp.lib

machine can be x64 with Tamd64-coff instead of Tx86-coff if your OS is 64 bit.

Basically must be a console app(-subsystem:console)(the source code has a main()),
with __cdecl calling conventions for functions (-Gd), but it will accept __stdcall
too (-Ze) (Windows APIs), by default POCC is not tolerant with the stdcall, and old
names for C functions are accepted (-Go)(for example the old sleep() instead of new
_sleep()).

Now you have two options:

1. hard way: you can play with the current project settings and at same point will compile,
and I recommend you this approach, everyday is a good day to learn something new, but don't
change the code, the code is exceptionally compilable given his length, I don't know if is
a working code, and I really don't care, but for sure you can compile this.

2. easy way:
   -First be sure the POIDE is closed, this is VERY important.
   -Make a new folder, where, it doesn't matter, but is better in Pelles C Projects.
   -Move the source code(in this case maprapimain.v1.0.1.c) inside the folder.
   -Right click on file ->Open if the default for C files is POIDE or ->Open with
      and pick POIDE from the list.
   -Go to Project(menu) and click "Build maprapimain.v1.0.1.c".
    The "New default project" dialog will popup, choose "console app", click Ok.
   -Click "execute" second toolbar button from right to left;
      one message and a error will appear in the output window: first from <unistd.h>
      and the error from <winnt.h> "no target architecture", the last one it is really
      important (the code mix C runtime with API).
   -Go to  project-project options-compiler-options
      and check "Enable Microsoft extensions" and "Define compatibility names".
   -Click "ok".
   -Click "execute".
   
   And that's it! Now you have only two minor warnings, deal with them.

   Be sure you have an unmodified source code, re unzip the C file.

Second problem.
This is easy, but it only works for projects not for single files( use instead for example
7-Zip is free and good). In the project tree right click on the top item usually "some.exe"
with bold, click "Zipp Project Files...".

Laur