[fpc-pascal] trying to use C code in .pas on WIN32

conlin664 conlin664 at yahoo.com
Mon Feb 4 23:59:13 CET 2019


THANKS GUYS.

This is now working. The 'fix' was to actually install fpc 3.0.4 on this
machine.
My trusty 2.4.4 still compiled just fine what I use it for here at my day
job.

But it seems 2.4.4 was not really pulling in the static reference.
{ $L ccode.o }

So for anyone else searching on this:

ccode.cpp

#include <stdint.h>
#include <stdio.h>

void HelloC(void)
{
   printf("Hello \n");
}


pcode.pas

program pcode;

{$L ccode.o }
{$linklib msvcrt}

uses
  ctypes, sysutils, dos, math;

procedure HelloC; cdecl; external name 'HelloC';

type
	UINT8  = 0..255;
	UINT16 = 0..65535;
	UINT32 = Longword;

begin
	writeln('Test');
	HelloC;
end.


compiled on WIN32 with:

@set ToolPath=C:\VCAST63\MinGW\bin
@set cc=%ToolPath%\gcc.exe

@set SAVED_PATH=%PATH%
@set PATH=%ToolPath%;%PATH%

@set BASE=%cd%

%CC% -g -I%BASE%  -DGNU_WIN32 -O1  -Wunused-variable   -c ccode.c -o ccode.o

rem %cc% -o test.exe ccode.o pcode.o  -lwsock32 

fpc -MDelphi  -vw -Sg  -Ci -O1  -OpPENTIUM3 -Ratt ^
-Fu%FPC_BASE%\units\i386-Win32 ^
-Fu%FPC_BASE%\units\i386-Win32\* ^
-Fu%FPC_BASE%\units\i386-Win32\rtl ^
-FlC:\VCAST63\MinGW\lib ^
pcode.pas

@set PATH=%SAVED_PATH%
@exit /b


thanks again!

john






--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/



More information about the fpc-pascal mailing list