โŒ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNewest questions tagged ada - Stack Overflow

Avoiding warning 8-bit Ada Boolean return type, use Char

I have been working on cleaning up warnings on pedantic code, and we treat warnings as errors. I have interface code between Ada and C++, which looks like this:

Ada manager.ads:

function Foo(ID_Type : in Integer) return Boolean;
pragma Import(CPP, Foo, "Foo");

C++ Adamanager.cpp:

extern "C" bool Foo(int32_t ID)
{
  return Manager::GetManager()->Bar(ID);
}

C++ Adamanager.h:

extern "C" bool Foo(int32_t ID);

C++ manager.cpp:

bool Manager::Bar(int32_t ID)
{
   //function body
   return answer;
}

C++ manager.h

static bool Bar(int32_t ID);

gcc -c output for manager.ads:

warning: return type of "Foo" is an 8-bit Ada Boolean
warning: use appropriate corresponding type in C (e.g. char)

I have a bunch of these cases.

To get rid of the warnings, do I need to replace all of the bools with char or some other 8-bit type and then do an explicit type conversion in the Ada body code? Why would the compiler choose to have the boolean be 8-bit?

โŒ
โŒ