mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
Branches: main Add two new options to the compiler for querying what flags are passed to the C compiler at a finer level of detail than that provided by --output-cflags. The first new option, --output-grade-defines, prints the flags passed to the C compiler to define the macros that specify the current compilation grade. The second new option, --output-c-include-dir-flags, prints the flags passed to C compiler that tell it where to search for C header files. The rationale for the addition of the new options is that when compiling C++ or Objective-C programs that call exported Mercury procedures via a standalone interface we need both the flags for the grade defines and the include search directories but other flags that we usually pass the C compiler may not be appropriate for either a C++ or Objective-C compiler. compiler/options.m: Recognise the new options. compiler/mercury_compile.m: Handle the new options. compiler/compile_target_code.m: Separate out the code that generates the grade macro define flags into a separate predicate. Do likewise with the code that generates the flags for specifying C compiler include search directories. doc/use_guide.texi: Document the new options. samples/c_interface/standalone_c/Makefile: Illustrate how to use the new options when compiling a program that uses a standalone interface. Explain why it may not be appropriate to use the output of --output-cflags when compiling code that calls exported Mercury procedures.
This directory contains some examples of mixed Mercury/C programs using
the C interface.
short_example.m A short example of Mercury code calling C.
mercury_calls_c A detailed example of Mercury code
calling C code.
c_calls_mercury A detailed example of C code calling
Mercury code.
mercury_calls_cplusplus A detailed example of Mercury code
calling C++ code.
cplusplus_calls_mercury A detailed example of C++ code calling
Mercury code.
mercury_calls_fortran This directory contains a detailed
example of Mercury code calling Fortran code.
simpler_c_calls_mercury A simpler example of C code calling Mercury.
simpler_cplusplus_calls_mercury A simpler example of C++ code calling
Mercury.
standalone_c Another example of C code calling Mercury
code this time use the compiler's
`--generate-standalone-interface' option.