Solved

C++ compiler error C2628: 'int8_t' followed by 'bool' is illegal (did you forget a ';'?)

Posted on 2014-11-12
5
677 Views
Last Modified: 2014-11-12
I'm trying to compile the code found on this sourceforge site http://sourceforge.net/projects/bacnet/files/bacnet-stack/, under the ports/Win32/VS2010 folder so I can integrate into a .NET application.

When trying to compile I get and error as in the title of this question. The source file in error is below:

#ifndef _STDBOOL_H
#define _STDBOOL_H

#include <stdint.h>

/* C99 Boolean types for compilers without C99 support */
/* http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html */
#if !defined(__cplusplus)

#if !defined(__GNUC__)
/* _Bool builtin type is included in GCC */
/* ISO C Standard: 5.2.5 An object declared as 
   type _Bool is large enough to store 
   the values 0 and 1. */
/* We choose 8 bit to match C++ */
/* It must also promote to integer */
typedef int8_t _Bool;
#endif

/* ISO C Standard: 7.16 Boolean type */
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1

#endif

#endif

Open in new window

0
Comment
Question by:wint100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 40436853
Hi wint100,

the code is only used to add bool type to compilers where it's not a built-in type like C-compilers before C99.

What compiler do you use? If you use a C++ compiler this code shouldn't be compiled at all coz '__cplusplus' is defined. This is because in C++ the bool is a built-in type. The code which fails to build is only intended to be built with a C-compiler.

If you compile it with a C99 compliant C compiler which has built-in bool which is not GCC (for which a comaprsione is there) you have to either change or simply remove the code.

Hope that helps,

ZOPPO
0
 
LVL 1

Author Comment

by:wint100
ID: 40436856
Hi,

I'm using Visual studio 2013 to compile this. Maybe this is a C build and I need to look at changing the compiler, any idea how this is done, I'm only used to using C# .NET applications.

Thanks
0
 
LVL 1

Author Comment

by:wint100
ID: 40436867
Ah, got it to compile by simply commenting out that part of the code:

//#if !defined(__GNUC__)
///* _Bool builtin type is included in GCC */
///* ISO C Standard: 5.2.5 An object declared as 
//   type _Bool is large enough to store 
//   the values 0 and 1. */
///* We choose 8 bit to match C++ */
///* It must also promote to integer */
//typedef int8_t _Bool;
//#endif

Open in new window

0
 
LVL 31

Expert Comment

by:Zoppo
ID: 40436870
Hi,

first check the extension of the source file - VisualStudio per default uses a C compiler for all *.c files and a C++ compiler for *.cpp, *.c++, *.cc, ...

If it is not a *.c file which includes the posted code you have to check the file's compile settings, it is possible to tell VisualStudio per file which compiler is used.

ZOPPO
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 40436877
Sorry, the last comment seems to be wrong: I wasn't able to find option to i.e. tell VisualStudio (I use 2010) to build a *.c file with a C++ compiler - I'm think previous VisualStudio versions had this, but it seem it's either vanished or I simply can't find ...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question