Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-08

Exporting vars

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mauricio Stefani

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?

Thank you,
Mauricio

Reply by email

Peter Vreman
Show quoted text 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?

cvar is only allowed in fpc or objfpc mode.

Reply by email

Unknown author
to Mauricio Stefani: Hello :-) Please, have anybody ever tryed to export variables to a source in C? I…
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.

Reply by email