473,383 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Bool

Why do my compiler error about:

parse error before `check_arrays' when executing this piece of code:

bool check_arrays(unsigned char* in_array){
if((global_IP[0] == *(in_array)) && (global_IP[1] == *(in_array+1)) &&
(global_IP[2] == *(in_array+2)) && (global_IP[3] == *(in_array+3))){
return true;
}
else{return false;}
}
Do I need some includes to use the "bool"???

Best Regards
Terry
Nov 13 '05 #1
6 7836
Terry Andersen a écrit:
Why do my compiler error about: <snip>
Do I need some includes to use the "bool"???

yes

#include <stdbool.h>

--
Marc.

Nov 13 '05 #2
On Mon, 18 Aug 2003, Marc Lasson wrote:
Terry Andersen a écrit:
Why do my compiler error about: <snip>
Do I need some includes to use the "bool"???

yes

#include <stdbool.h>


This only holds true for C99 compilers. The older compilers do not have a
stdbool.h header. For older compilers you will have to create your own
defines or see if the compiler has implemented a header similar to the
stdbool.h header.
--
Marc.


--
main(){int j=1234;char t[]=":@abcdefghijklmnopqrstuvwxyz.\n",*i=
"iqgbgxmdbjlgdv.lksrqek.n";char *strchr(const char *,int);while(
*i){j+=strchr(t,*i++)-t;j%=sizeof t-1;putchar(t[j]);} return 0;}

Nov 13 '05 #3

"Jan Engelhardt" <je*****@linux01.gwdg.de> wrote in message
news:Pi*******************************@yvahk01.tjq t.qr...
> Why do my compiler error about:
> Do I need some includes to use the "bool"???
yes
#include <stdbool.h>
This only holds true for C99 compilers. The older compilers do not have a
stdbool.h header. For older compilers you will have to create your own
defines or see if the compiler has implemented a header similar to the
stdbool.h header.


What is the deal with bool, anyway? It is just a char (at least! it might

be an int.)


Just a way to express what you mean.
"char x(int)" is less obvious than "bool x(int)". Nonetheless I never use
bool in C. (although my compiler has the header) Because it's a macro it
does break a lot of existing code
Nov 13 '05 #4

"Serve La" <ik@hier.nl> wrote in message
news:bh**********@news2.tilbu1.nb.home.nl...
Just a way to express what you mean.
"char x(int)" is less obvious than "bool x(int)". Nonetheless I never use
bool in C. (although my compiler has the header) Because it's a macro it
does break a lot of existing code


ah, drop the "because it's a macro" part
Nov 13 '05 #5
in comp.lang.c i read:
What is the deal with bool, anyway? It is just a char (at least! it might
be an int.)


not in c99 it isn't if <stdbool.h> has been included. in c99 a bool (aka a
_Bool) can have only two values, 0 or 1.

--
a signature
Nov 13 '05 #6
Darrell Grainger wrote:
On Mon, 18 Aug 2003, Marc Lasson wrote:
Terry Andersen a écrit:

Why do my compiler error about:

<snip>
Do I need some includes to use the "bool"???

yes

#include <stdbool.h>


This only holds true for C99 compilers. The older compilers do
not have a stdbool.h header. For older compilers you will have to
create your own defines or see if the compiler has implemented a
header similar to the stdbool.h header.


I simply #include "stdops.h", which is the following:

/* Standard defines of operators, usable on C90 up */
#ifndef stdops_h
#define stdops_h
#if defined(__STDC__) && (__STDC_VERSION__ >= 199901L)
/* The following from C99 - must define for C90 */
#include <stdbool.h> /* define bool, true, false */
#include <iso646.h> /* define not, and, or, xor */
#else
#define false 0
#define true 1
typedef int bool;
#define not !
#define and &&
#define or ||
#define xor ^
#endif
#endif
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pierre Espenan | last post by:
A have a long integer class. The built integer type within a conditional statement returns bool false for int i=0 and bool true for any other non zero value. I want my long integer class to have...
4
by: Nomak | last post by:
Hello, With this code: $ cat -n ifs.cc 1 #include <vector> 2 #include <iostream> 3 4 using std::vector; 5 using std::cin;
19
by: daniel | last post by:
1) is C++ smart enough to automatically use "bits" for bool or will a bool have the size of a charcter (byte). 2) The index of a vector is it an integer (4 byte) or a "long long" with 8 bytes or...
4
by: ORC | last post by:
Is the bool type actually an Int32 with 0 as false and non zero as true? The reason for my question is that I've seen a lot of API calls that return a Int32 implemented in C# as an bool like: ...
10
by: Mark Jerde | last post by:
I'm trying to learn the very basics of using an unmanaged C++ DLL from C#. This morning I thought I was getting somewhere, successfully getting back the correct answers to a C++ " int SumArray(int...
1
by: Bern McCarty | last post by:
What do you make of this? I cannot tell for sure but it almost seems as the the transition thunk to get back from the native bool method to the managed caller is looking at eax and, if any bit is...
4
by: gpg | last post by:
I am using a legacy DLL and need to marshal some structures for use in the DLL. For the most part, I have figured out my needs except for one small item. I have a structure that contain, among...
6
by: zl2k | last post by:
hi, there I am using a big, sparse binary array (size of 256^3). The size may be changed in run time. I first thought about using the bitset but found its size is unchangeable. If I use the...
64
by: shaanxxx | last post by:
I have code which says #define MYBOOL int This code is very old. people who have written is not avaible. I was thinking what could be reason. 1) bool datatype was not available that time (10...
3
by: markb | last post by:
Hi My C# app is being called from a callback from an unmanaged DLL. One of the parameters of the callback is of type BOOL. I am using PInvoke to marshal this to a (managed) bool. The problem is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.