Fix __LINE__ and __FILE__ expansion. Mostly this did not work at all.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12192 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-08-26 18:06:02 +00:00
commit 69af82caa4
5 changed files with 116 additions and 13 deletions

View file

@ -0,0 +1,33 @@
%module preproc_line_file
%javaconst(1);
// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying)
#define MYLINE __LINE__
#define MYLINE_ADJUSTED __LINE__ + 100
#define MYFILE __FILE__
#define MYFILE_ADJUSTED __FILE__ ".bak"
#define STRINGNUM_HELP(a,b) #a#b
#define STRINGNUM(a,b) STRINGNUM_HELP(a,b)
#define STRINGNUM_UNIQUE(a) STRINGNUM(a,__LINE__)
#define MY_STRINGNUM_A STRINGNUM_UNIQUE(my)
#define MY_STRINGNUM_B STRINGNUM_UNIQUE(my)
#define NUMBER_HELP(a,b) a##b
#define NUMBER(a,b) NUMBER_HELP(a,b)
#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
#define MYLINE2 __LINE__
/*
TODO: __LINE__ is wrong
struct Struct {
static const int line_num = __LINE__;
};
const int NUMBER_UNIQUE(thing) = 0;
const int NUMBER_UNIQUE(thingamebob) = 0;
#define MYLINE3 __LINE__
*/