Commit fb40b8b1 authored by ken's avatar ken

[project @ 2001-07-23 23:08:04 by ken]

Rearranged the usage help message to move --no-compile to the bottom.

More importantly-- Fixed: hsc2hs was translating

    #def inline ... function(...) { ... }

into (assuming defined(__GNUC__))

    [in the _hsc.h file:]  extern inline ... function(...)
    [in the _hsc.c file:]  inline ... function(...)

while it should really be translated into

    [in the _hsc.h file:]  extern inline ... function(...)
    [in the _hsc.c file:]  ... function(...)

(without the "inline" in the _hsc.c file).  Quoting the gcc documentation
for "inline":

>    If you specify both `inline' and `extern' in the function
> definition, then the definition is used only for inlining.  In no case
> is the function compiled on its own, not even if you refer to its
> address explicitly.  Such an address becomes an external reference, as
> if you had only declared the function, and had not defined it.
>    This combination of `inline' and `extern' has almost the effect of a
> macro.  The way to use it is to put a function definition in a header
> file with these keywords, and put another copy of the definition
> (lacking `inline' and `extern') in a library file.  The definition in
> the header file will cause most calls to the function to be inlined.
> If any uses of the function remain, they will refer to the single copy
> in the library.
parent 1a6d581f
-- $Id: Main.hs,v 1.30 2001/04/02 16:10:05 rrt Exp $
-- $Id: Main.hs,v 1.31 2001/07/23 23:08:04 ken Exp $
-- Program for converting .hsc files to .hs files, by converting the
-- file into a C program which is run to generate the Haskell source.
......@@ -52,12 +52,12 @@ options = [
Option "I" [] (ReqArg (CompFlag . ("-I"++))
"DIR") "passed to the C compiler",
Option "L" ["lflag"] (ReqArg LinkFlag "FLAG") "flag to pass to the linker",
Option "" ["no-compile"] (NoArg NoCompile) "stop after writing *_hsc_make.c",
Option "i" ["include"] (ReqArg include "FILE") "as if placed in the source",
Option "D" ["define"] (ReqArg define "NAME[=VALUE]") "as if placed in the source",
Option "o" ["output"] (ReqArg Output "FILE") "name of main output file",
Option "" ["help"] (NoArg Help) "display this help and exit",
Option "" ["version"] (NoArg Version) "output version information and exit"]
Option "" ["version"] (NoArg Version) "output version information and exit",
Option "" ["no-compile"] (NoArg NoCompile) "stop after writing *_hsc_make.c",
main :: IO ()
main = do
......@@ -433,7 +433,7 @@ output flags name toks = do
progName = outDir++outBase++"_hsc_make" ++ progNameSuffix
outHName = outDir++outBase++"_hsc.h"
outCName = outDir++outBase++"_hsc.c"
let execProgName
| null outDir = "./"++progName
| otherwise = progName
......@@ -649,19 +649,20 @@ outTokenC (pos, key, arg) =
"def" -> case arg of
's':'t':'r':'u':'c':'t':' ':_ -> ""
't':'y':'p':'e':'d':'e':'f':' ':_ -> ""
'i':'n':'l':'i':'n':'e':' ':_ ->
outCLine pos++
"#ifndef __GNUC__\n\
"\n#ifndef __GNUC__\n\
'i':'n':'l':'i':'n':'e':' ':arg' ->
case span (\c -> c /= '{' && c /= '=') arg' of
(header, body) ->
outCLine pos++
"#ifndef __GNUC__\n\
\extern inline\n\
"\n#ifndef __GNUC__\n\
_ -> outCLine pos++arg++"\n"
where (header, body) = span (\c -> c /= '{' && c /= '=') arg
_ | conditional key -> outCLine pos++"#"++key++" "++arg++"\n"
_ -> ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment