Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Bug in generated eCos <sys/endian.h>

I added some code that needed to do a little byte-swapping, and it refused to compile. First it coughed up a set of errors like:

${INSTALL_DIR}/include/sys/endian.h:183: error: `cyg_uint32&#39; does not name a type

So I added# include <cyg/infra/cyg_type.h>, wondering why the header file didn&#39;t do it itself. Then I got errors on the same line of the form:

${INSTALL_DIR}/include/sys/endian.h:183: error: `htobe32&#39; does not name a type

So I went and looked at the header, and lo and behold, starting at line 183 it looks like:

cyg_uint32    htobe32 __P((cyg_uint32));
cyg_uint16    htobe16 __P((cyg_uint16));
cyg_uint32    betoh32 __P((cyg_uint32));
cyg_uint16    betoh16 __P((cyg_uint16));
cyg_uint32    htole32 __P((cyg_uint32));
cyg_uint16    htole16 __P((cyg_uint16));
cyg_uint32    letoh32 __P((cyg_uint32));
cyg_uint16    letoh16 __P((cyg_uint16));
# if BYTE_ORDER == LITTLE_ENDIAN
/* Can be overridden by machine/endian.h before inclusion of this file.  */# ifndef _QUAD_HIGHWORD# define _QUAD_HIGHWORD 1# endif# ifndef _QUAD_LOWWORD# define _QUAD_LOWWORD 0# endif
# define htobe16 swap16# define htobe32 swap32# define betoh16 swap16# define betoh32 swap32
# define htole16(x) (x)# define htole32(x) (x)# define letoh16(x) (x)# define letoh32(x) (x)
# endif /* BYTE_ORDER */

etc.

Commenting out those 8 lines starting with "cyg_" fixed the problem, and it built fine.

So my question is, where did that come from, and how to fix it?
No RepliesBe the first to reply