Ross Paterson | 24 Apr 2006 13:22
Picon
Favicon

cvs commit: www/Hugs/pages downloading.htm

ross        2006/04/24 04:22:09 PDT

  Modified files:
    Hugs/pages           downloading.htm 
  Log:
  link to Fedora Extras

  Revision  Changes    Path
  1.63      +4 -4      www/Hugs/pages/downloading.htm
Ross Paterson | 24 Apr 2006 17:29
Picon
Favicon

cvs commit: www/Hugs/pages downloading.htm

ross        2006/04/24 08:29:57 PDT

  Modified files:
    Hugs/pages           downloading.htm 
  Log:
  accent

  Revision  Changes    Path
  1.64      +1 -1      www/Hugs/pages/downloading.htm
Ross Paterson | 26 Apr 2006 14:26
Picon
Favicon

cvs commit: hugs98/src runhugs.c

ross        2006/04/26 05:26:44 PDT

  Modified files:
    src                  runhugs.c 
  Log:
  Dummy implementation of updateTimers() for runhugs to get --enable-timers
  working (fixes #19).

  Revision  Changes    Path
  1.23      +8 -2      hugs98/src/runhugs.c
Neil Mitchell | 26 Apr 2006 15:43
Picon
Gravatar

Compiling ffihugs

Hi,

Where is the main procedure for ffihugs? I'm not sure really where it
is, or how to go about building it. Just a general pointer to the
main, and I should be able to chase the dependancies from there.

Thanks

Neil
Ross Paterson | 26 Apr 2006 15:54
Picon
Favicon

Re: Compiling ffihugs

On Wed, Apr 26, 2006 at 02:43:23PM +0100, Neil Mitchell wrote:
> Where is the main procedure for ffihugs? I'm not sure really where it
> is, or how to go about building it. Just a general pointer to the
> main, and I should be able to chase the dependancies from there.

It's runhugs.c compiled with -DFFI_COMPILER (sorry: it wasn't me).
Neil Mitchell | 26 Apr 2006 16:15
Picon
Gravatar

cvs commit: hugs98/src/msc hugs.sln ffihugs.vcproj

neil        2006/04/26 07:15:47 PDT

  Modified files:
    src/msc              hugs.sln 
  Added files:
    src/msc              ffihugs.vcproj 
  Log:
  Add an ffihugs project for visual studio

  Revision  Changes    Path
  1.2       +8 -0      hugs98/src/msc/hugs.sln
Neil Mitchell | 26 Apr 2006 18:29
Picon
Gravatar

Using hugsffi

Hi,

I now can build ffihugs, and have added some patches so it finds
visual studio etc. I'm currently have ffihugs do something
"unexpected" - but I'm not sure what the real behaviour is...

-- test.hs
import Foreign
import System.Environment

main = print $ c_test 1 2

foreign import ccall unsafe "test.h test" c_test :: Int -> Int -> Int

-- test.c
int test(int a, int b){return 42;}

-- test.h
int test(int a, int b);

Then I run (as per http://cvs.haskell.org/Hugs/pages/users_guide/ffihugs.html):

ffihugs test.hs test.c

And before compiling hugs has clobbered test.c, and removed my code
from it. This gives a link error, since test is undefined.

Is this how ffihugs is supposed to work? Should my code be going somewhere else?

Thanks
(Continue reading)

Ross Paterson | 26 Apr 2006 18:35
Picon
Favicon

Re: Using hugsffi

On Wed, Apr 26, 2006 at 05:29:57PM +0100, Neil Mitchell wrote:
> ffihugs test.hs test.c
> 
> And before compiling hugs has clobbered test.c, and removed my code
> from it. This gives a link error, since test is undefined.
> 
> Is this how ffihugs is supposed to work? Should my code be going somewhere else?

It generates Foo.c from Foo.hs, so yes, you need to call your C file
something else.  I'll update the docs, as the example given there
fails on a case-insensitive filesystem.
Ross Paterson | 26 Apr 2006 18:53
Picon
Favicon

cvs commit: hugs98/docs/users_guide others.xml

ross        2006/04/26 09:53:29 PDT

  Modified files:
    docs/users_guide     others.xml 
  Log:
  fix the ffihugs example for Windows
  (presumably the -lm is wrong too?)

  Revision  Changes    Path
  1.3       +19 -10    hugs98/docs/users_guide/others.xml
Neil Mitchell | 26 Apr 2006 19:55
Picon
Gravatar

Windows FFI patch

Hi,

Attached is a patch that is useful (but not essential) for Windows FFI
to work slightly better.

Hugs builds up a command line that it passes to the compiler, for example:

gcc -blah1 <filename> -blah2

In certain compilers -blah2 would not apply to <filename>, as a result
when compiling with MSVC, the use of blah2 after <filename> generates
a warning, but still works. The simple solution is the attached patch
which moves -blah2 before <filename>.

Does this harm gcc? If not then its probably a useful patch. If yes,
then I'll get over it.

There are a few other patches required for FFI - since the command
line used by Hugs in the tree hasn't worked with visual studio
compilers for a long time - I'll commit some patches tonight.

With these tweaks, ffihugs works just great with windows. The only
thing potentially missing is a warning that your carefully written C
file is about to be trashed by ffihugs if you do the "obvious" thing.
Or perhaps hugs should use a different name for the file generates,
like test.temp.hugs.c ? Just anything thats less likely to clash.

Thanks

Neil
(Continue reading)


Gmane