I will clearly explain our present software structure
in solaris and how the exporting/importing will takes
place.
It consists of hundreds of modules and programs
written in C and Pascal ,functions interaction will be
in below combinations
a) C functions defined in C Programs will be called
from Pascal Modules and Programs
b) Pascal functions defined in One Pascal module will
be called from other Pascal Modules and Programs
I)PASCAL MODULE STRUCTURE
a)MODULE XXXX
/* module name xxxx */
b)…
[View More]INCLUDE FILES
/* they will contain user defined data types and
macros, these files are standard incluide files for
all
our modules*/
c)IMPORTING INCLUDE FILES
/*these files will contain the functions to be
imported from the other module */
/* C-functions will be called like below
FUNCTION set_bit(mask : INTEGER;
bit_position : INTEGER): INTEGER;
EXTERNAL C;
Actually the above function is defined pas_c.c
file.pas_c.c is compiled to pas_c.o and linked to
the modules which will use the functions defined in
pas_c.c.
/* Pascal-functions will be called from other Pascal
modules like below
FUNCTION mininteger(First, Second: INTEGER): INTEGER;
EXTERN;
Actually the above function is defined pasmath.pas
file. pasmath.pas is compiled to pasmath.o and linked
to the modules which will use the functions defined in
pasmath.pas.But the function definition of the
FUNCTION mininteger(First, Second: INTEGER): INTEGER;
in pasmath.pas should be prceeded by the keyword
'PUBLIC' so that other modules can use this.
d)BODY OF THE MODULE
/* Main Code Part */
II)C PROGRAM STRUCTURE
a)STANDARD HEADER FILES
/*stdio.h*/
b)INCLUDE FILES
/* they will contain user defined data types and
macros */
c)FUNCTION PROTOTYPES
d)FUNCTION DEFINITIONS
Hope, I have explained clearly.
with the sun pascal and c compilers we donot need to
have export clause explicitly.linking will take care
of it automatically
when one function from a module is called in another
module/program.Using EXTERN and EXTERN C keywords we
can specify the compilers
that the functions are not defined in the current
module but in the linked modules.
My request is what should i do to compile this code
using GNU compilers without doing major modifications
in my present structure.
Regards
Hari
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
[View Less]
Hi Folks!
Welcome to the wonderful world of SQLite3.
SQLite3 is a library that implements an SQL database
engine. The database is stored in one file, not in
many files and the engine itself is not a kind of
server, which makes it interesting for me to put my
databases in such files. See http://www.sqlite.org/ for
more details.
I've written a unit which is an interface to SQLite3. You may
download the unit from
http://www.gnu-pascal.de/contrib/eike/sqlite3-gpc-20051025.tar.gz
Eike
In a message dated 10/25/2005 6:25:40 AM Eastern Standard Time,
v_sriharikumar(a)yahoo.com writes:
> I want to write a macro which should compatible with
> gpc version 2.1 and look like below
>
> #define PAS_EXTERNAL_C(X) asmname 'X'
>
> suppose if i define a macro like above, it should be
> preprocessed like below
>
> Before preprocessing:
>
> procedure Hello; PAS_EXTERNAL_C(Hello);
>
> After preprocessing:
>
> procedure Hello; …
[View More]asmname 'Hello';
>
> I am worried why
> #define PAS_EXTERNAL_C(X) asmname 'X'
> this is not working?
>
> Please help me
>
> Regards
> Hari
Using the Pascal Macro Compiler you can produce the desired results this way.
You define the macro procedure PAS_EXTERNAL_C like this,
%Procedure PAS_EXTERNAL_C (X: code);
%begin
asmname _quote%x%_quote;
%end;
Before macro expansion you would write
procedure Hello; %PAS_EXTERNAL_C (Hello);
After macro expansion you would get
procedure Hello; asmname 'Hello';
as required.
Frank Rubin
[View Less]
Dear All
Is it possible to have export clause at the end of
module/program in gpc version 2.1 as my porting will
becomes much easier
regards
Hari
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
I want to write a macro which should compatible with
gpc version 2.1 and look like below
#define PAS_EXTERNAL_C(X) asmname 'X'
suppose if i define a macro like above, it should be
preprocessed like below
Before preprocessing:
procedure Hello; PAS_EXTERNAL_C(Hello);
After preprocessing:
procedure Hello; asmname 'Hello';
I am worried why
#define PAS_EXTERNAL_C(X) asmname 'X'
this is not working?
Please help me
Regards
Hari
__________________________________
…
[View More]Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
[View Less]
I just checked that Free Pascal accepts the followig program:
program keyw;
var absolute, external, overload, override, virtual,
abstract, reintroduce : integer;
begin
end
.
gpc -fdelphi says:
keyw.p:2: error: `absolute' is a keyword in Borland Pascal
keyw.p:2: error: `external' is a keyword in UCSD Pascal, Borland Pascal,
keyw.p:2: error: traditional Macintosh Pascal
keyw.p:2: error: `virtual' is a keyword in Object Pascal, Borland Pascal,
keyw.p:2: error: traditional Macintosh …
[View More]Pascal
It seems that all of them as treated as "directives" and hence may
work also as variable names.
Could some kind soul check how other compilers behave -- if the names
are really directives then we should teach gpc to accept them as
variable names in those dialects.
--
Waldek Hebisch
hebisch(a)math.uni.wroc.pl
[View Less]
LastReadWriteStrFDR is used to cache an FDR to avoid allocating and
releasing one for each use of ReadStr, Val etc.
Unfortunately, the memory is leaked since it is never freed and there
is no way to cause it to be freed. This causes my leak detection
routines to fire on termination of my program.
I've added to files.pas:
procedure DisposeReadWriteStr; attribute (name = '_p_DisposeReadWriteStr');
procedure DisposeReadWriteStr;
begin
if LastReadWriteStrFDR <> nil then
begin
…
[View More] InternalDispose (LastReadWriteStrFDR);
LastReadWriteStrFDR := nil
end
end;
which cannot do any damage since LastReadWriteStrFDR is just a cache
and calling it before checking for leaks solves my problem, but:
* the name DisposeReadWriteStr is pretty dubious
* I'm not convinced this is the best way to do it
* perhaps exposing LastReadWriteStrFDR is a better solution (then at
least I could detect the leak matches that and hide it)
a to end do block could clean up the LastReadWriteStrFDR FDR, but
that would not happen until after my code had all completed and so
I'd still register the leak.
This also highlights a risk involved in using the
GetMemPtr/FreeMemPtr/ReAllocMemPtr variables to define replacement
memory allocators. Since some allocations (eg StdErr's FDR) are
allocated before my code can be executed, they are allocated with the
default memory allocator and not with mine. It is therefore
imperitive that they not be freed until after I have replaced the
FreeMemPtr with the original (CFreeMem). So the RTS needs to be
careful that anything that is allocated within _p_initialize is not
freed until _p_finalize, and also nothing allocated after
_p_initialize completes and user code starts can be freed safely in
_p_finalize.
I'm open to any suggestions on any of this.
Peter.
--
<http://www.stairways.com/> <http://download.stairways.com/>
[View Less]
Thanks for the reply
I am using below compiler flags
PFLAGS = -L -w -tc -fnonstd -ftrap=%all -DSOLARIS
-DL_SOLARIS -Qoption cpp -C -Qoption cpp -DSOLARIS
Please find below the explanation of unavailable flags
in gpc
-fnonstd
-fnonstd = The -fnonstd option causes nonstandard
initialization of floating-point arithmetic hardware.
By default, IEEE 754 floating-point arithmetic is
nonstop, and underflows are gradual. (See the
Numerical Computation Guide for details.) The -…
[View More]fnonstd
option causes hardware traps to be enabled for
floating-point overflow, division by zero, and invalid
operation exceptions. These hardware traps are
converted into SIGFPE signals, and if the program has
no SIGFPE handler, it terminates with a memory dump.
-fnonstd also causes the math library to be linked in
by passing -lm to the linker.
This option is a synonym for -fns -ftrap=common.
-tc
-tc =The -tc option instructs the compiler to generate
pc3 stab information that allows cross-module type
checking.
This option can be used for two purposes:
To check for any name conflicts that your program may
have with the standard libraries with which it is to
be linked, such as libc. The linker allows name
conflicts, which may cause erroneous runtime behavior
in your program.
For example, the following program has a name conflict
with libc:
program p(output);
var time: integer;
begin
writeln(wallclock);
end.
When the program is compiled with the -tc option, pc3
issues a warning that the name time is already defined
as a libc routine. Running a.out causes a core dump.
To avoid this problem, change the name of the variable
that has the conflict--in this case, time.
To check for possible name conflicts in the various
modules of your program. These conflicts arise if you
define a routine with the same name in several
modules, or refer to an external, but undefined,
variable. The linker detects these error situations
and does not create the executable file.
hostname% {$w-}
-Qoption
The -Qoption passes an option to the program. The
option value must be appropriate to that program and
can begin with a plus or minus sign. The program value
can be either cpp(1), cppas, iropt, ld(1), ild(1),
pc0, or pc3. For example, the following command passes
the option -R to cpp and allows recursive macros:
hostname% pc -Qoption cpp -R myprog.p
Regards
Hari
__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
[View Less]
Dear All
My projects requires calling C function in a pascal
program.Is it possible with gpc? If so please tell me
how to implement it.
Regards
Hari
__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
Dear All
I am trying to make use of gpc compiler(2.1 version)
in solaris 2.8 platform.For testing
purpose I have written two sample programs,one for
creating a module and another is a program.
program will call the function defined in the module.
I am compiling those programs by make use of a make
file.
When I am trying to call a function from library it is
giving linking problem.Below I am pasting the
code and make file.Please correct my code sothat it
facilitates me to call the function …
[View More]from library and
also please make the corrections if any in the make
file.
***************************************
program ModDemo3 (Output);
begin
WriteLn ('program writeln');
xtra;
end.
***************************************
module DemoMod3;
procedure xtra ;
begin
writeln('from library');
end;
end.
**************************************
PC=gpc
PFLAGS= -DSOLARIS -L/home/kvsspl
VPATH = /home/kvsspl/
DemoMod3.o : DemoMod3.pas
$(PC) -c $(PFLAGS) DemoMod3.pas
ModDemo3.o : ModDemo3.pas
$(PC) -c $(PFLAGS) ModDemo3.pas
ModDemo3 : DemoMod3.o ModDemo3.o
$(PC) -o ModDemo3 DemoMod3.o ModDemo3.o \
**********************************************************
Please treat it as urgent and help me
Regards
Hari
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
[View Less]