
Hi Manuel,
I am trying to use the conditional compilation feature of the latest release of c2hs. My
code looks something like this:
#include

Axel Simon
I am trying to use the conditional compilation feature of the latest release of c2hs. My code looks something like this:
#include
#if GTK_CHECK_VERSION(2,2,0)
treeStoreRemove :: (TreeStoreClass ts) => ts -> TreeIter -> IO Bool treeStoreRemove ts ti = liftM toBool $ {#call tree_store_remove#} (toTreeStore ts) ti
#else
treeStoreRemove :: (TreeStoreClass ts) => ts -> TreeIter -> IO () treeStoreRemove ts ti = {#call tree_store_remove#} (toTreeStore ts) ti
#endif
First of all there is a but that a newline in front of each # is lost so that cpp conditionals wind up on the line above (which was of course a comment, so passed unnoticed...).
You mean that c2hs drops the newline in front of each cpp directive?
But more important is that the test yields true but c2hs compiles the second version. The created .h file looks like this:
#include "gtk/gtktreestore.h" #include
#if GTK_CHECK_VERSION(2,2,0) struct C2HS_COND_SENTRY_1; #else #endif I don't know how the mechanism is to work but I though that with C2HS_COND_SENTRY_1 defined code segment #1 would be inserted and similar for a C2HS_COND_SENTRY_2 which is kind of missing.
The mechanism works by c2hs running the generated .h through cpp and then checking whether or not `C2HS_COND_SENTRY_1' is defined in the pre-processed header. Anyway, I just checked your example and I think I messed something up in the released version. I'll have a closer look and let you know once it's fixed. Thanks, Manuel

On Wed, Apr 16, 2003 at 12:19:45AM +1000, Manuel M. T. Chakravarty wrote:
First of all there is a but that a newline in front of each # is lost so that cpp conditionals wind up on the line above (which was of course a comment, so passed unnoticed...).
You mean that c2hs drops the newline in front of each cpp directive? Ups, yes. That is exactly what the sentence above should say.
Anyway, I just checked your example and I think I messed something up in the released version. I'll have a closer look and let you know once it's fixed. Thanks, Axel.

Axel Simon
On Wed, Apr 16, 2003 at 12:19:45AM +1000, Manuel M. T. Chakravarty wrote:
First of all there is a but that a newline in front of each # is lost so that cpp conditionals wind up on the line above (which was of course a comment, so passed unnoticed...).
You mean that c2hs drops the newline in front of each cpp directive? Ups, yes. That is exactly what the sentence above should say.
I vaguely remember having seen this behaviour at some point, but my versions seems to handle this correctly.
Anyway, I just checked your example and I think I messed something up in the released version. I'll have a closer look and let you know once it's fixed.
Check out http://www.cse.unsw.edu.au/~chak/haskell/c2hs/c2hs-0.11.3.tar.gz It should resolve the problem with conditionals. Thanks for the bug report, Manuel
participants (2)
-
Axel Simon
-
Manuel M T Chakravarty