[CMake] Including a header file fails

Enrique Izaguirre enrique.izaguirre at gmail.com
Tue Mar 1 18:34:26 EST 2011


Hello,

I have a program called fastboot.c which #includes util_windows.h which
#includes windows.h which finally #includes winbase.h where all the
constants are defined. The errors I get are because the Makefile I got from
CMake, doesn't find the constants, as shown:

/host/fastboot.h:101: warning: ISO C does not allow extra `;' outside of a
functi
/host/fastboot.c:93: error: `NOPARITY' undeclared here (not in a function)
/host/fastboot.c:112: error: `NOPARITY' undeclared here (not in a function)
/host/fastboot.c:112: error: initializer element is not constant
/host/fastboot.c:112: error: (near initialization for
`parity_names[0].value')
/host/fastboot.c:112: error: initializer element is not constant
/host/fastboot.c:112: error: (near initialization for `parity_names[0]')
/host/fastboot.c:113: error: `ODDPARITY' undeclared here (not in a function)
/host/fastboot.c:113: error: initializer element is not constant
/host/fastboot.c:113: error: (near initialization for
`parity_names[1].value')
/host/fastboot.c:113: error: initializer element is not constant
/host/fastboot.c:113: error: (near initialization for `parity_names[1]')
/host/fastboot.c:114: error: `EVENPARITY' undeclared here (not in a
function)
/host/fastboot.c:114: error: initializer element is not constant
/host/fastboot.c:114: error: (near initialization for
`parity_names[2].value')
/host/fastboot.c:114: error: initializer element is not constant
/host/fastboot.c:114: error: (near initialization for `parity_names[2]')
/host/fastboot.c:115: error: `MARKPARITY' undeclared here (not in a
function)
/host/fastboot.c:115: error: initializer element is not constant
/host/fastboot.c:115: error: (near initialization for
`parity_names[3].value')
/host/fastboot.c:115: error: initializer element is not constant
/host/fastboot.c:115: error: (near initialization for `parity_names[3]')
/host/fastboot.c:116: error: `SPACEPARITY' undeclared here (not in a
function)
/host/fastboot.c:116: error: initializer element is not constant
/host/fastboot.c:116: error: (near initialization for
`parity_names[4].value')
/host/fastboot.c:116: error: initializer element is not constant
/host/fastboot.c:116: error: (near initialization for `parity_names[4]')
/host/fastboot.c:118: warning: missing braces around initializer
/host/fastboot.c:118: warning: (near initialization for `parity_names[5]')
/host/fastboot.c:118: error: initializer element is not constant
/host/fastboot.c:118: error: (near initialization for `parity_names[5]')
/host/fastboot.c: In function `find_named_value':
/host/fastboot.c:125: warning: implicit declaration of function `stricmp'
/host/fastboot.c: In function `open_device_callback':
/host/fastboot.c:302: warning: implicit declaration of function `sleepms'
/host/fastboot.c: In function `open_device':
/host/fastboot.c:313: warning: unused variable `timeremaining'
/host/fastboot.c: In function `usage':
/host/fastboot.c:382: warning: string length `2787' is greater than the
length `5
upport
/host/fastboot.c: In function `offset_and_chip_name':
/host/fastboot.c:729: warning: unused variable `addr'
/host/fastboot.c: In function `arg':
/host/fastboot.c:845: error: `EVENPARITY' undeclared (first use in this
function)
/host/fastboot.c:845: error: (Each undeclared identifier is reported only
once
/host/fastboot.c:845: error: for each function it appears in.)
/host/fastboot.c:848: error: `NOPARITY' undeclared (first use in this
function)


All those constants as mentioned are in winbase.h

how can I say CMake where to look? I used include_directories ( ) and it
didn't work.
Also:  util_windows.h is in the same directory as fastboot.c
windows.h and winbase.h are in
    ${MYPRJ_SOURCE_DIR}/../../../usr/include/w32api

which is the one I tried to include inside include_directories ( )

Thanks a lot

Enrique

On Tue, Mar 1, 2011 at 5:03 PM, Andreas Pakulat <apaku at gmx.de> wrote:

> On 01.03.11 14:58:15, Enrique Izaguirre wrote:
> > I tried several ways but I cannot make it work. The only thing I need to
> do
> > is to add a folder which contains a windows header file, in order that it
> be
> > included in the build.
> > There must be a simple way to do it. Could you help?
>
> Header files are not included into the build, they are included in a cpp
> source file and that cpp file is then added to the build into an
> add_executable call. Once you have that and if it gives you errors, post
> the complete error messages here.
>
> Andreas
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110301/d7fceb26/attachment.htm>


More information about the CMake mailing list