On 21/04/2012, at 4:04 PM, john skaller wrote:

> 
> If you look at the code, the trick I use is like this:
> 
>  pod type stat_t = "struct stat" requires Posix_headers::sys_stat_h;
>  gen chmod: string * mode_t -> int = "chmod($1.c_str(),$2)" requires 
> Posix_headers::sys_stat_h;
> 
> So if you use the type stat_t anywhere OR you call chmod, you get sys_stat_h 
> dragged in.
> Otherwise, you don't.


BTW: the trend in Felix is to get rid of explicit includes as such, and use
package requirements instead. 

These "vector" through the config/*.fpc files, which means you can more
easily change things. For example if you targeted some other platform,
you might change the includes required for some function.

Of course you might think this doesn't apply to standard files like
those for C or Posix .. think again!

Special hackery may be needed to get gcc to stop using the non-standard
GNU_SOURCE functions. Actually for one of these I can't figure out
how to force gcc to use the Posix standard functions instead of its own.
Generally we want to allow GNU extensions but Standards should override
these. 

I forget which function it is but the GNU function is downright
stupid, returning a useless pointer instead of an error code, and there
is no way to write error checking code that works with both variants
(short of conditional compilation in Felix which sucks, or a wrapper,
which is almost impossible because, as I said, the GNU code in
this case is stupid).

Some cases where we want to use package requirements might
include <inttypes.h> and <stdint.h> where the native compiler doesn't
supply the headers, the headers are wrong, or they just don't include
definitions like "intptr_t" and "int64_t" that we'd like to require,
instead of using configure time tests (which suck utterly) and generating
platform dependent library code.

This sucks completely because it means the library is no longer
platform independent.

The *right* way to do this kind of thing is have specs for each platform,
and then select the desired one (possibly at run time).

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to