Rob Sanders
Rob Sanders

Reputation: 5347

C import #defines from header file

I'm using Xcode to develop little C command line tools and I have a header file that looks like this:

#define Bool unsigned char;
#define YES ((Bool) 1);
#define true ((Bool) 1);
#define NO ((Bool) 0);
#define false ((Bool) 0);

In another .c file I'm importing the header file like so

#include "Definitions.h"

Whenever I use Bool or true or false Xcode gives me the following warnings:

Type specifier missing, defaults to 'int'

Declaration does not declare anything

For a function like so:

enter image description here

If I take out the include "Definitions.h" and just put the defines in the c file all the warnings go away.

What is going on here?

Upvotes: 1

Views: 1335

Answers (1)

kdopen
kdopen

Reputation: 8215

Remove all the semi-colons from your #define statements!

Beyond that, there is no need to define these types. They are already there in <stdbool.h> which gives you bool, true, and false.

Upvotes: 5

Related Questions