Now we're trying to get stuff working on Windows, we need a model
for portable code. Note there's a trickiness needed here:

a) Cygwin can do both posix and windows functions,
so it may not be "one or the other"

b) We still need to write platform specific code

c) All OS .. especially posix .. have extensions and variations,
indeed some lameness is found in compilers, especially gcc,
when trying to get *their* extensions too, without conflicting
with standards (some _GNU_SOURCE routines conflict
with Posix and gcc folks haven't been smart enough to provide
a way to get the Posix standard stuff without losing the desired
gnu extensions .. grrr .. )

At present the goal is to get "flx" to work. This is probably not
that hard. Windows actually provides most of the C std library
and a lot of posix emulation stuff already.

For example, there's no "stat()" function in windows but there
is a set of _stat functions. The stat buffer even has gid in it,
even though it's always 0.

So a core model is something like:

std/filestat.flx               // portable
std/posix/filestat.flx    // posix code
std/win32/filestat.flx   // win32 code

where the portable code goes in std/filestat.flx PLUS 
conditional compilation. That will, unfortunately, also have stuff like:

if WIN32 do
include "std/win32/filestat";
else
include "std/posix/filestat";
done

The problem with this is that you also get Posix or Win32 specific functions
you can accidentally call. If you consider:

POSIX:
  pod type stat_t = "struct stat" requires Posix_headers::sys_stat_h;
  proc stat: string * &stat_t * &int = "*$3=stat($1.c_str(),$2);";

WIN32:
  pod type stat_t = "struct __stat64" requires Posix_headers::sys_stat_h;
  proc stat: string * &stat_t * &int = "*$3=_stat64($1.c_str(),$2);";
 
however you see the Felix interface is the same. However there's actually
a completely different (and better) way to do this on Windows using
GetFileInfoEx or something.


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




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to