โŒ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

How is Ada and GPR supposed to handle conditional compilation? [duplicate]

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;

Can the gnat compiler find unused specification procedures/functions/variables?

Is there a warning option switch that will identify spec-level procedures, functions, or variables that are not called or referenced anywhere? I've tried the switches below without luck.

This is what I'm currently using: -gnatwfilmopuvz -- m turn on warnings for variable assigned but not read -- u turn on warnings for unused entity -- v turn on warnings for unassigned variable

When I move unused variables from the spec to the body, the compiler correctly identifies them as not referenced. I would like to understand why the compiler won't identify unused code in the spec, and if there is a way to get it to do so. An excessive number of warnings isn't a concern, because I use the filter field in gnat studio to only look at a few files at a time, and I can easily filter to ignore library packages.

Any help is very appreciated.

โŒ
โŒ