NO

Author Topic: wrong header  (Read 5073 times)

jjsa

  • Guest
wrong header
« on: September 27, 2012, 04:39:09 PM »
If a project using socket functions and a little bit more is to be compiled for Windows 7, I get errors.
Apparently the type (structure) NDIS_OBJECT_HEADER is declared later as the first use. In order to compile the project, there is a work around (for me), but this is not the correct way:
#ifdef __POCC__
#define _NETIOAPI_H
#endif


The following code allows to reproduce the problem:
------------------------------------------------------------
// file bug.c
#define _WIN32_WINNT 0x0601

#include <stdio.h>
#include <stdlib.h>

//#include <windows.h> // Error
// PellesC\Include\Win\windot11.h(24): error #2078: Invalid struct field declarations.
// PellesC\Include\Win\windot11.h(24): error #2001: Syntax error: expected '}' but found 'NDIS_OBJECT_HEADER'.

#include <winsock2.h>
#include <ws2tcpip.h>

#include <iphlpapi.h> // Error as for windows.h


int __cdecl main(void)
{
    printf("Hello\n");
    return 0;
}
-----------------------------------------------------------

The hand made  Makefile look as follows:

----------------------------------------------------------
INCLUDE = -I"$(PellesCDir)\Include\Win" -I"$(PellesCDir)\Include"
LIB     = /LIBPATH:"$(PellesCDir)\Lib\Win" /LIBPATH:"$(PellesCDir)\Lib"

CFLAGS = /std:C99 -Tx86-coff /Ot /Ob1 /fp:precise /W1 /Gz /Ze $(INCLUDE)
LDFLAGS = /subsystem:console /machine:x86 $(LIB) kernel32.lib user32.lib wsock32.lib ws2_32.lib iphlpapi.lib
ASFLAGS = -AIA32 -Gz

LINK=polink
CC=pocc

bug.exe: bug.obj
   $(LINK) $(LDFLAGS) /out:bug.exe bug.obj

bug.obj: bug.c
   $(CC) $(CFLAGS) bug.c /Fo bug.obj

clean:
   del bug.obj bug.exe
----------------------------------------------------------


CommonTater

  • Guest
Re: wrong header
« Reply #1 on: September 27, 2012, 06:04:20 PM »
Always place <winsock2.h> above <windows.h> and generally you should include windows headers before library headers ... a lesson I learned the hard way.

Try it like this and see if that helps...

Code: [Select]

#define WIN32_DEFAULT_LIBS  // Pelles C specific, see appendix to help file
 
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>

#include <stdio.h>
#include <stdlib.h>


(fwiw ... it's like this in vc++ as well ... winsock before windows)
« Last Edit: September 27, 2012, 06:11:16 PM by CommonTater »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: wrong header
« Reply #2 on: September 27, 2012, 08:06:56 PM »
Always place <winsock2.h> above <windows.h> and generally you should include windows headers before library headers ... a lesson I learned the hard way.
winsock2.h includes windows.h if it isn't included...
May the source be with you

jjsa

  • Guest
Re: wrong header
« Reply #3 on: September 27, 2012, 08:33:16 PM »
The position of windows.h or it ommission is not important.
The problem is that the structure I mentionned is declared after the first uses.

CommonTater

  • Guest
Re: wrong header
« Reply #4 on: September 27, 2012, 08:55:15 PM »
The position of windows.h or it ommission is not important.
The problem is that the structure I mentionned is declared after the first uses.

Yeah it does matter... however that doesn't seem to be what's causing this particular problem...

Strange...



Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: wrong header
« Reply #5 on: September 27, 2012, 08:57:34 PM »
Maybe there is a error in ntddndis.h at line 1000
Move that code to lower near end.
Code: [Select]
#if ((NTDDI_VERSION >= NTDDI_VISTA) || NDIS_SUPPORT_NDIS6)
#ifndef _WINDOT11_H
#include <windot11.h>
#endif
#endif /* NTDDI_VERSION >= NTDDI_VISTA */
May the source be with you

CommonTater

  • Guest
Re: wrong header
« Reply #6 on: September 27, 2012, 09:02:22 PM »
Maybe there is a error in ntddndis.h at line 1000
Move that code to lower near end.
Code: [Select]
#if ((NTDDI_VERSION >= NTDDI_VISTA) || NDIS_SUPPORT_NDIS6)
#ifndef _WINDOT11_H
#include <windot11.h>
#endif
#endif /* NTDDI_VERSION >= NTDDI_VISTA */

or perhaps
 
#define NTDDI_VERSION NTDDI_VISTA
 
at the top of his source page
 

 

jjsa

  • Guest
Re: wrong header
« Reply #7 on: September 27, 2012, 09:12:21 PM »
The file has to be corrected for all peles C user,  for my project I have a work around and I expect that the delivered header files are correct. my posting is only a bug report.