Recent

Author Topic: Error: Identifier not found "VirtualAlloc" Why?  (Read 6451 times)

indi4ever

  • Newbie
  • Posts: 3
Error: Identifier not found "VirtualAlloc" Why?
« on: March 19, 2014, 04:36:14 am »
I am new to Lazarus, but not to OP programming. I have used Delphi for years. I installed Lazarus 1.2 Win32 (on win64 win7 system), and am attempting to install packages. I am unable to because VirtualAlloc is not recognized. This is a winapi call. Where is this defined in FPC? and why is it not found upon an install of lazarus?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Error: Identifier not found "VirtualAlloc" Why?
« Reply #1 on: March 19, 2014, 04:45:57 am »
what packages where did you found them if they are your own home made components then you either use the search in files functionality to search for virtualalloc or redeclare it on one of your own units. You have to remember that lazarus is focused on the cross platform support first and then on functionality so if there is no cross platform for a windows functionality then there will not be defined or shared with lazarus.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

indi4ever

  • Newbie
  • Posts: 3
Re: Error: Identifier not found "VirtualAlloc" Why?
« Reply #2 on: March 19, 2014, 06:12:07 am »
Ok, it is "Delphi ASIO & VST", but with .lpk files for Lazarus installation. Unfortunately the developer is pretty much absent from the project now. It has a compiler.inc file with the following directives defined:

{ Set FreePascal to Delphi mode }
{$IFDEF FPC}
  {$MODE DELPHI}
  {$ASMMODE Intel}
  {$UNDEF BORLAND}
  {$DEFINE CPUASM} // FPC defines CPU32, CPU64 and Unix automatically

  {$IFDEF Darwin}
    {$DEFINE MACOS}
    {-$DEFINE PUREPASCAL} // for OSX use pure pascal code
  {$ENDIF}
{$ENDIF}

And in the unit (DAV_Common) it has

{$IFDEF FPC}
uses LCLIntf, DAV_Types; {$DEFINE PUREPASCAL}
{$ELSE}
uses
  {$IFDEF MSWINDOWS} Windows, {$ENDIF}
  {$IFDEF UseNativeTypes}Types, {$ENDIF}
  DAV_Types;
{$ENDIF}     

The call occurs in a {$IFDEF MSWINDOWS} block.

Are these not enough?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Error: Identifier not found "VirtualAlloc" Why?
« Reply #3 on: March 19, 2014, 11:57:28 am »
Certainly no. {$IFDEF MSWINDOWS} is inside outer {$ELSE} of {$IFDEF FPC}

indi4ever

  • Newbie
  • Posts: 3
Re: Error: Identifier not found "VirtualAlloc" Why?
« Reply #4 on: March 19, 2014, 12:30:28 pm »
Ok, Thanks. Given that there are over 40,000 lines of code, I'll just chalk this up as unusable in Lazarus. 

Oh, do I not need to add the source path to an environment variable somewhere? I had to do that in Delphi before I installed the packages. There were no instructions to do so in Lazarus, and I don't see a place to do that. The IDE Options panel (under files) lists Lazarus and FPC directories, but they don't look like the place to add 3rd party component paths (if that is needed at all).

Anyway, thanks for answering my questions.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12901
  • FPC developer.
Re: Error: Identifier not found "VirtualAlloc" Why?
« Reply #5 on: March 19, 2014, 01:58:58 pm »
Ok, Thanks. Given that there are over 40,000 lines of code, I'll just chalk this up as unusable in Lazarus. 

The code apparently only used Lazarus for non-windows, so that will be major rename. Oversimplistic ifdef  systems are a common problem when converting Delphi code, specially library code.

Quote
Oh, do I not need to add the source path to an environment variable somewhere? I had to do that in Delphi before I installed the packages. There were no instructions to do so in Lazarus, and I don't see a place to do that.

No, the packages are compiled into the lazarus.EXE and no bpl's are required, and thus their sourcepath neither.


Quote
The IDE Options panel (under files) lists Lazarus and FPC directories, but they don't look like the place to add 3rd party component paths (if that is needed at all).

If an application uses a package, you need to add a dependency from the application on the package (project inspector -> required packages in the tree). Then Lazarus automatically adds the paths from the package.

The advantage of this is that if you transfer a project from one lazarus to the other, both with the packages installed, but not in the same paths, it will work without modification. It is one of the Lazarus features that I love the most.
 

 

TinyPortal © 2005-2018