Sign in Join

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

Mailing lists / fpc-devel / 2007-03

strange error with arm compiler when compiling-running this code

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Roozbeh GHolizadeh

I have a big project in c,and i wanted to somehow use it in fpc,so i compiled the code with evc(embedded visual c compiler 4.0 of microsoft)and linked it to my pascal code.
i dont know why but i just get errors in evc + fpc in arm.bcc32 + delphi and vs.net + fpc both compiles and run ok.(also bcc32 + fpc wont work,illegal coff magic error)
Any ideas?

my c code :

typedef struct
{

  char *name;

}
namestruct;

#define NULL ((void *)0)

static namestruct namestructs[8] = {
{"Not Implemented"},
{"Not Implemented"},
{"Not Implemented"},
{"Not Implemented"},
{"Not Implemented"},
{"Not Implemented"},
{"Not Implemented"},
{"Not Implemented"},
};

int
strcasecmp (char *s1, char *s2)
{
if (s2 == NULL)

		return 1;
	if (s1 ==NULL)
		return 1;
	//return 0;
	if (*s2 == 0) //error is generated here in arm

mode!whenever accessing *s2!and it seems s2 is also not a null pointer

		return 1;
	return 0;
	while (*s1 /*&& toupper (*s1) == toupper (*s2)*/)
    {
      s1++;
      s2++;
    }
return *s1 - *s2;
}

int findname (char *s)
{

  int i;
  for (i = 8; i; i--)
    if (strcasecmp (s, namestructs[i].name) == 0)
      return i;

//changing strcasecmp (s, namestructs[i].name) to
strcasecmp (s, NULL) also makes code ok!

  return 0;

}

my pascal code :

{$apptype console}
{$link testpchar.o}
function findname (s : PChar) :
cardinal;cdecl;external name 'findname';
var
s:string;
begin
writeln('start');
s:='hi'#0#1;
writeln(findname(pchar(s)));
writeln('end');
end.

regard,
roozbeh

____________________________________________________________________________________ It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar. http://tools.search.yahoo.com/toolbar/features/mail/

Reply by email

Michael Schnell
to Roozbeh GHolizadeh
I have a big project in c,and i wanted to somehow use it in fpc,so i compiled the code with evc(embedded visual c compiler 4.0 of microsoft)and linked it to my pascal code.

Why do you think it's possible to link the evc output with something that is not compiled using evc ? What linker is specified to do that ?

-Michael

Reply by email

Florian Klaempfl
to Michael Schnell
Show quoted text 7 lines
> I have a big project in c,and i wanted to somehow use > it in fpc,so i compiled the code with evc(embedded > visual c compiler 4.0 of microsoft)and linked it to my > pascal code. Why do you think it's possible to link the evc output with something that is not compiled using evc ?

It should be possible to link at least evc compiled C code with FPC. The C files in the test suite are compiled by evc. Modern C compiler use COFF as object format which is used by FPC as well.

What linker is specified to do that ?

The internal linker should be able to do so.

Reply by email

Michael Schnell
to Florian Klaempfl
It should be possible to link at least evc compiled C code with FPC. The C files in the test suite are compiled by evc. Modern C compiler use COFF as object format which is used by FPC as well.

Microsoft is not very famous to strictly adhere to standards...

-Michael

Reply by email