Jump to content
William23668

Undeclared identifier: '_CONTEXT'

Recommended Posts

Hi

I was compiling a component and got this error

 

[DCC Error] Winapi.Windows.pas(1404): E2003 Undeclared identifier: '_CONTEXT'

 

Code:

TContext = _CONTEXT;
CONTEXT = _CONTEXT;
{$EXTERNALSYM CONTEXT}

Why I get this error ?

Share this post


Link to post
Posted (edited)

Why are you re-compiling Winapi.Windows.pas?  You should not be doing that.

 

In any case, Winapi.Windows.pas declares the _CONTEXT record only if the CPUX64 or CPUX86 conditional is defined.  Perhaps they are not defined in your situation?

 

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post
4 minutes ago, Remy Lebeau said:

Why are you re-compiling Winapi.Windows.pas?  You should not be doing that.

 

In any case, Winapi.Windows.pas declares the _CONTEXT record only if the CPUX64 or CPUX86 conditional is defined.  Perhaps they are not defined in your situation?

 

It is old Android app when I compile it give me the above error. I tried compile Android 32bit and 64bit. Is there something else to do ?

Share this post


Link to post
Posted (edited)
6 minutes ago, William23668 said:

It is old Android app when I compile it give me the above error. I tried compile Android 32bit and 64bit. Is there something else to do ?

The Winapi.Windows unit is for Windows builds only.  If the component is trying to use that unit in an Android build, then its code is not IFDEF'ed properly to separate any platform-specific code, and thus needs to be fixed accordingly.

Edited by Remy Lebeau
  • Like 2

Share this post


Link to post
3 minutes ago, Remy Lebeau said:

The Winapi.Windows unit is for Windows only, you can't use it on Android. Which means if the component is trying to use that unit on an Android build then its code is not IFDEF'ed properly. 

Yes 

  _CONTEXT define like this inside

IFDEF  
_CONTEXT = record

. But I can not modify this source file to make _CONTEXT inside IFDEF

Share this post


Link to post
13 minutes ago, William23668 said:

Yes 

  _CONTEXT define like this inside


IFDEF  
_CONTEXT = record

. But I can not modify this source file to make _CONTEXT inside IFDEF

Remy wanted to point out that the WINDOWS or WINAPI unit must not be present in an Android program and that IFDEF is normally used to distinguish Android from Windows (if the program must be multiplatform).
Look in the USES of your program and REMOVE all the references to WINDOWS or WINAPI (or use IFDEF in your source to divide the platforms of use and include or not those units.).

  • Like 2

Share this post


Link to post
2 minutes ago, DelphiUdIT said:

Look in the USES of your program and REMOVE all the references to WINDOWS or WINAPI

Ok. Will check all files.

Share this post


Link to post
3 hours ago, DelphiUdIT said:

Remy wanted to point out that the WINDOWS or WINAPI unit must not be present in an Android program and that IFDEF is normally used to distinguish Android from Windows (if the program must be multiplatform).

Yes, exactly, for example:

uses
  ...
  {$IFDEF MSWINDOWS}, Winapi.Windows{$ENDIF}
  {$IFDEF ANDROID}, Androidapi.SomeOtherUnit{$ENDIF}
  ...
;

 

  • Like 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×