2

I'm rewriting C source to Ada and on some places there is conditional compilation for handling different platforms, such as windows vs posix, DEBUG, or architecture. For what I can tell neither Ada nor GPR has the notion of conditional compilation.

What's the Ada way of handling it?

Example:

/* Determine if a process is alive. */
#ifndef _WIN32
   if (kill(pid, 0) && errno == ESRCH)
      return 0; /* pid does not exist */
#else
   HANDLE h;
   if ((h = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, (DWORD)pid)) == 0)
      return 0; /* pid does not exist */
   CloseHandle(h);
#endif
   return 1;
Andreas
  • 5,086
  • 3
  • 16
  • 36
  • 4
    You might find some inspiration from [this question](https://stackoverflow.com/q/72206798/40851) & its answers – Simon Wright Nov 28 '22 at 21:47
  • Although not part of the Ada standard, GNAT has a preprocessor. See https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gnat_ugn_unw/Preprocessing.html – habrewning Dec 05 '22 at 18:19
  • @SimonWright Out of the answers the scenario variables are what works for me. – Andreas Dec 05 '22 at 20:00

0 Answers0