Now, suppose your C/C++ program needs a library, in Unix called /usr/lib/libfoo.so or /usr/lib/libfoo.a.
To use it we first create the file config/foo.fpc which looks like this: /////////////////////////////// provides_dlib: -lfoo provides_slib: -lfoo /////////////////////////////// The file should be put in the 'config' directory used by the Felix installation. Now in you code you can write: //////////////////////////////////////////// #import <flx.flxh> body "#define main PROXY_MAIN"; proc main: int * &(charp) = "exit(main($1,$2));"; main(System::argc, System::_argv); requires package "foo"; requires body '#include "foo.h"'; body cr""" #include <stdio.h> int main(int argc, char *argv[]) { printf("Hello World argc=%d, argv[1]=%s\n", argc, argc>1?argv[1]:"None" ); foo(); return 42; } """; ///////////////////////////////////////////// The requires package clause creates a dependency on foo.fpc which in turn causes the right linker switches to be use to link in the library automatically. The requires body clause causes the header file to be included, so that the call foo() in your code binds to a declared function. We COULD have put the #include directly in the body, but we chose not to here. ISSUE: wouldn't it be good not to have to do the #include separately? It is possible to do this: body foo_h = 'include "foo.h"'; body foo_p = requires package "foo"; body foo = foo_h, foo_p; requires foo; but the question is: why isn't the header file provided by the fpc package?? Should I change it? At present flxg doesn't have to read and parse fpc files. We could make it do so. I do NOT like this, because the files should be 'platform independent'. At present, Felix generated C++ will compile and run on any platform (modulo one platform dependent include file). OR we could do this: #include foo // foo is a MACRO and then make the C++ compiler have the switch -Dfoo="\"foo.h\"" (although that is super ugly if the command line is itself quoted .. :) In that case, flx script can call flx_pkgconfig to retrieve the requisite information. Another trick would be to simply prepend some text to the front of files. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language