Reputation: 1513
If I decided to use an enum, such as this one:
typedef enum {
FALSE, TRUE = !FALSE
} bool;
as a parameter, and a return type in this function:
bool foo(bool param)
{
<do something>
return TRUE;
}
Would it cause any problems? for example, across compilers.
PS: I don't intend to use #include <stdbool.h>
Upvotes: 2
Views: 175
Reputation: 67546
As I understand this is only an example and your actual type names will not collide with something "standard'. Using enum types as parameters and return values is 100% OK and safe.
Upvotes: 1
Reputation: 73366
Since you don't intend to #include <stdbool.h>
(which might cause conflicts), there should not be a problem with your approach.
However, if this is a big project, where others contribute too, then I wouldn't recommend you to go on with your approach, because they might include that header. Moreover, if you decide to use that code in a future project of yours, I am pretty sure that would not remember that detail with this prevention of including that header, except if you document it nicely.
Upvotes: 3