Recent

Author Topic: $SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE  (Read 2904 times)

440bx

  • Hero Member
  • *****
  • Posts: 4023
$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE
« on: November 21, 2021, 02:28:03 am »
Hello,

I figured I'd try the "$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE" in a program but the compiler isn't liking it.

With FPC v3.0.4, I get the error:
Code: Text  [Select][+][-]
  1. Error: Identifier not found "IMAGE_FILE_LARGE_ADDRESS_AWARE"

With FPC v3.2.2, I get the error:
Code: Text  [Select][+][-]
  1. Error: Compile time expression: Wanted Integer but got AnsiString at SETPEFLAGS

What's the magic incantation to make that option work ? :)

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: $SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE
« Reply #1 on: November 21, 2021, 07:33:31 am »
Hi
This is how I work.
Code: Pascal  [Select][+][-]
  1. {$SetPeFlags $0020}
By the way, I want to talk about an interesting situation.
It works when Code is first added to the unit. Then if the unit is recompiled without any changes, it doesn't work.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: $SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE
« Reply #2 on: November 21, 2021, 07:41:17 am »
the constant IMAGE_FILE_LARGE_ADDRESS_AWARE is defined in defines.inc, which is part of the windows unit.
so add the windows unit to your uses clause, then set the flag after the uses , should work fine.

uses windows, ........

{$SetPeFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

440bx

  • Hero Member
  • *****
  • Posts: 4023
Re: $SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE
« Reply #3 on: November 21, 2021, 08:15:55 am »
Thank you loaded and Josh.

I didn't think about the fact that the directive must appear _after_ the Windows unit. 

Thank both again, that was very helpful.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: $SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE
« Reply #4 on: November 21, 2021, 01:32:22 pm »
I didn't think about the fact that the directive must appear _after_ the Windows unit. 

I should have mentioned that in the other thread, but the directives $SetPEFlags and $SetPEOptFlags either take an integer value, an integer constant identifier (3.0.x) or an integer constant expression (which in turn can contain constant values or identifiers) (3.2+). And the identifiers need to be in scope of course. ;)

 

TinyPortal © 2005-2018