Mercury Bugs - mercury
View Issue Details
0000346mercuryBugpublic2014-07-11 17:412016-10-06 20:27
Reporterwangp 
Assigned Towangp 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000346: non-ANSI functions in header files
Descriptiondir.mih references DIR, but is included into C files compiled with gcc -ansi. For some reason this elicits an error from the gcc on AIX but seemingly not elsewhere.

There might be other similar problems.
TagsNo tags attached.
Attached Files

Notes
(0000739)
juliensf   
2014-07-11 20:08   
It might be worth adding the dir module to the list of files in library/Mercury.options that are compiled with --no-ansi.

OTOH, we should probably just not use -ansi at all -- IIRC, it (still) puts GCC into C90 mode (annoyingly it puts clang into C89 or GNU89 mode, which is slightly different).
(0000743)
wangp   
2014-07-14 10:26   
Yes, I don't understand why dir.m hasn't required --no-ansi yet.

The bigger problem is that the non-ANSI stuff leaks into the header files generated for dir.m and ends up being included into almost everything else. That stuff should be hidden away, and only appear in `local' foreign_decls, foreign_codes, and foreign_procs marked `may_not_duplicate'.
(0000744)
juliensf   
2014-07-14 10:31   
I'd perfectly happy simply to not use -ansi with GCC. (I had to disable its use with clang recently anyway.)
Another problem with it is that it affects the compilation of user foreign_procs. Most of the systems we
support these days support POSIX / C99 well enough that disabling it isn't going to be a problem.
The one major system that doesn't, Windows, already requires special treatment everywhere anyway.
(0000745)
juliensf   
2014-07-14 10:33   
All that said, restricting the stuff in the dir module to appear in 'local' foreign pragmas is also a worthwhile
change IMO.
(0000934)
wangp   
2016-10-06 20:27   
Fixed as part of commit 1fbcfe3 (for dir.m anyway)

Issue History
2014-07-11 17:41wangpNew Issue
2014-07-11 20:08juliensfNote Added: 0000739
2014-07-14 10:26wangpNote Added: 0000743
2014-07-14 10:31juliensfNote Added: 0000744
2014-07-14 10:33juliensfNote Added: 0000745
2016-10-06 20:27wangpAssigned To => wangp
2016-10-06 20:27wangpStatusnew => resolved
2016-10-06 20:27wangpResolutionopen => fixed
2016-10-06 20:27wangpNote Added: 0000934