for review: Avoid including mercury_imp.h in generated .h files.
Tyson Dowd
trd at cs.mu.OZ.AU
Thu Aug 20 18:43:23 AEST 1998
Hi,
Anyone interested can review this.
It's not exactly a critical change, but it makes things easier to manage
when interfacing with C++, and doesn't really do any harm otherwise.
===================================================================
Estimated hours taken: 0.75
Allow the #include "mercury_imp.h" in generated header files to be
avoided (#define MERCURY_IMP_H isn't quite enough because it will still
look for mercury_imp.h in the include path).
We need this because we want to use these prototypes in C++, but don't
want to start including the Mercury header files (in fact, I'd prefer
to keep the include paths quite separate).
compiler/export.m:
Generate
#ifndef MERCURY_EXCLUDE_IMP_H
#include "mercury_imp.h"
#endif
in the generated .h file for exported Mercury predicates.
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.24
diff -u -r1.24 export.m
--- export.m 1998/07/08 20:55:59 1.24
+++ export.m 1998/08/20 08:34:24
@@ -483,60 +483,52 @@
% Should this predicate go in llds_out.m?
+export__produce_header_file([], _) --> [].
export__produce_header_file(C_ExportDecls, ModuleName) -->
+ { C_ExportDecls = [_|_] },
+ module_name_to_file_name(ModuleName, ".h", yes, FileName),
+ io__tell(FileName, Result),
(
- { C_ExportDecls = [_|_] }
+ { Result = ok }
->
- module_name_to_file_name(ModuleName, ".h", yes, FileName),
- io__tell(FileName, Result),
- (
- { Result = ok }
- ->
- module_name_to_file_name(ModuleName, ".m", no,
- SourceFileName),
- { library__version(Version) },
- io__write_strings(
- ["/*\n** Automatically generated from `",
- SourceFileName,
- ".m' by the\n** Mercury compiler, version ",
- Version,
- ". Do not edit.\n*/\n"]),
- { llds_out__sym_name_mangle(ModuleName,
- MangledModuleName) },
- { string__to_upper(MangledModuleName,
- UppercaseModuleName) },
- { string__append(UppercaseModuleName, "_H",
- GuardMacroName) },
- io__write_strings([
- "#ifndef ", GuardMacroName, "\n",
- "#define ", GuardMacroName, "\n",
- "\n",
- "#ifdef __cplusplus\n",
- "extern ""C"" {\n",
- "#endif\n",
- "\n",
- "#include ""mercury_imp.h""\n",
- "\n"]),
- export__produce_header_file_2(C_ExportDecls),
- io__write_strings([
- "\n",
- "#ifdef __cplusplus\n",
- "}\n",
- "#endif\n",
- "\n",
- "#endif /* ", GuardMacroName, " */\n"]),
- io__told
- ;
- io__progname_base("export.m", ProgName),
- io__write_string("\n"),
- io__write_string(ProgName),
- io__write_string(": can't open `"),
- io__write_string(FileName),
- io__write_string("' for output\n"),
- io__set_exit_status(1)
- )
+ module_name_to_file_name(ModuleName, ".m", no, SourceFileName),
+ { library__version(Version) },
+ io__write_strings(["/*\n** Automatically generated from `",
+ SourceFileName,
+ ".m' by the\n** Mercury compiler, version ", Version,
+ ". Do not edit.\n*/\n"]),
+ { llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
+ { string__to_upper(MangledModuleName, UppercaseModuleName) },
+ { string__append(UppercaseModuleName, "_H", GuardMacroName) },
+ io__write_strings([
+ "#ifndef ", GuardMacroName, "\n",
+ "#define ", GuardMacroName, "\n",
+ "\n",
+ "#ifdef __cplusplus\n",
+ "extern ""C"" {\n",
+ "#endif\n",
+ "\n",
+ "#ifndef MERCURY_HDR_EXCLUDE_IMP_H\n",
+ "#include ""mercury_imp.h""\n",
+ "#endif\n",
+ "\n"]),
+ export__produce_header_file_2(C_ExportDecls),
+ io__write_strings([
+ "\n",
+ "#ifdef __cplusplus\n",
+ "}\n",
+ "#endif\n",
+ "\n",
+ "#endif /* ", GuardMacroName, " */\n"]),
+ io__told
;
- []
+ io__progname_base("export.m", ProgName),
+ io__write_string("\n"),
+ io__write_string(ProgName),
+ io__write_string(": can't open `"),
+ io__write_string(FileName),
+ io__write_string("' for output\n"),
+ io__set_exit_status(1)
).
:- pred export__produce_header_file_2(c_export_decls, io__state, io__state).
--
Tyson Dowd # There isn't any reason why Linux can't be
# implemented as an enterprise computing solution.
trd at cs.mu.oz.au # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.
More information about the developers
mailing list