robotology / yarp

YARP - Yet Another Robot Platform
http://www.yarp.it
Other
531 stars 195 forks source link

YARP will not build on platform where ``sizeof(short) != 2`` #383

Open drdanz opened 9 years ago

drdanz commented 9 years ago

From conf/YarpSystemCheck.cmake

if(SIZEOF_SHORT EQUAL 2)
    set(YARP_INT16 "short")
else(SIZEOF_SHORT EQUAL 2)
    # Hmm - there's no other native type to get 16 bits
    # We will continue since most people using YARP do not need one.
    message(STATUS "Warning: cannot find a 16 bit type on your system")
    message(STATUS "Continuing...")
endif(SIZEOF_SHORT EQUAL 2)

from conf/template/yarp_config_numeric.h.in

#define YARP_INT16 ${YARP_INT16}

this will become yarp/conf/numeric.h

#define YARP_INT16

YARP_INT16 is used in several parts of the code (i.e. for defining NetInt16 and NetUInt16), therefore the build will fail, for example in src/libYARP_OS/include/yarp/os/NetInt16.h

 typedef YARP_INT16 NetInt16;

will become (after preprocessor)

 typedef NetInt16;

that will cause an error like ‘NetInt16’ does not name a type. (There are probably several other places where something like this will happen).

Anyway, I don't know if this is a real issue and if there are platform where sizeof(short) is NOT 2, but it might be worth either fixing YARP to build without a 16 bit variable, or raising a FATAL_ERROR instead of the informative STATUS message in YarpSystemCheck.cmake

drdanz commented 9 years ago

Also note that in C99/C++11 stdint.h defines int16_t, but according to the documentation:

Optional: These typedefs are not defined if no types with such characteristics exist.