Mauricio Stefani wrote 11 lines
Hello :-)
Please, have anybody ever tryed to export variables to a source in C?
I couldn't get it to work with the cvar modifier... The compiler shows me an
error message:
test : integer; cvar;
Error line ... : expecting : found ;
Is that right? Please, what's the mistake?
This is not right; You are probably using {$mode tp} or the -So switch;
this causes that error to appear (cvars are not allowed in -So mode)
The following compiles fine with no mode set:
unit testv;
Interface
Var
c : Pchar; cvar;
Implementation
begin
C:='Some string';
end.
and it links perfectly with
#include <stdio.h>
extern char * c;
int main () {
printf("%s",c);
return 0;
}
The output is (null), since the initialization section was not called from the C program, so this is normal.
Michael.