Pascal Viandier wrote:
I would like to submit a case on which I spent some time. It occurred with sources converted to GPC from SUN Pascal with an automated script.
In the interface section of a module, the following statements:
Export MyModule = (A); .... Var A : Integer = 4; attribute(static); ....
This module compiles with no complaint. However for all modules importing MyModule -AND- using A, gpc issues the <error undefined reference to 'A'>.
The problem is: SUN Pascal understands the "static" directive as in C, so the statements above are correct and work - as in C -, but not for GPC.
How so? In C, static means file-scope, i.e. static declarations are not visible from other files:
/* a.c */
static int a;
/* b.c */
extern int a;
int main () { a = 42; }
# gcc a.c b.c /tmp/ccKBFfHh.o: In function `main': b.c:(.text+0x1e): undefined reference to `a'
Doesn't work in C.
I know the difference between the two "static" flavours but it would have been of great help if gpc had issued at least a warning when compiling MyModule. Something like: "Cannot export a static variable" had saved me some difficult hours.
Yes, this might be useful.
I did not found any reference to the directive "static" in the 7185 or 10206
Yes, it's a nonstandard extension.
Frank