Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


TinyCC CCode Cannot Compile WinAPI Headers

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
HighVoltage
How do I cheat?
Reputation: 0

Joined: 04 Dec 2023
Posts: 8

PostPosted: Sat Oct 26, 2024 3:57 pm    Post subject: TinyCC CCode Cannot Compile WinAPI Headers Reply with quote

Hello, I seem to be having an issue with{$c} / {$ccode} clauses when it comes to #include'ing WinAPI headers; TinyCC just keeps throwing "random" compilation errors for windows headers.

I have tried everything, such as using addCIncludePath(getCheatEngineDir()) and even compileTCCLib() in a {$lua} block prior to enabling the C code, to no avail.

From what I see on the Forums (cannot link URLs), headers such as <winapi.h> should be includable at the very least.

(This is a default Cheat Engine 7.5 installation without any modifications.)

Sample Code:

Quote:

Code:
{$lua}
  if syntaxcheck then return end
  path = getCheatEngineDir()
  addCIncludePath(path)
  addCIncludePath(path .. "include\\")
  addCIncludePath(path .. "include\\winapi\\")
  compileTCCLib()
{$asm}

[ENABLE]

{$ccode}
    #include <windows.h>
{$asm}

[DISABLE]



Error Output:

Quote:

Not all code is injectable
(C Error :In file included from <string-0>:5:
In file included from C:/Program Files/Cheat Engine
7.5/include/winapi/windows.h:66:
In file included from C:/Program Files/Cheat Engine
7.5/include/winapi/windef.h:122:
In file included from C:/Program Files/Cheat Engine
7.5/include/winnt.h:80:
C:/Program Files/Cheat Engine
7.5/include/winapi/basetsd.h:109: error: function without
file scope cannot be static
)
Are you sure you want to edit it to this?




EDIT: It is worth mentioning that the "error" changes (but is still otherwise "random") when I change {$ccode} to {$c} in the aforementioned code:

New Error:


Quote:

Not all code is injectable
(C Error :In file included from <string-0>:2:
In file included from C:/Program Files/Cheat Engine
7.5/include/winapi/windows.h:66:
In file included from C:/Program Files/Cheat Engine
7.5/include/winapi/windef.h:122:
C:/Program Files/Cheat Engine
7.5/include/winapi/winnt.h:1516: error: invalid operand
reference after %
)
Are you sure you want to edit it to this?

Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Sat Oct 26, 2024 4:31 pm    Post subject: Reply with quote

try adding #define NO_OLDNAMES before the include
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
HighVoltage
How do I cheat?
Reputation: 0

Joined: 04 Dec 2023
Posts: 8

PostPosted: Sat Oct 26, 2024 4:36 pm    Post subject: Reply with quote

Dark Byte wrote:
try adding #define NO_OLDNAMES before the include


Thank you for the quick response, Dark Byte!

Sorry, I forgot to mention that I had tried #define NO_OLDNAMES (following your advise from Forum Topic 5788378); unfortunately, it did not change the errors, both for {$c} and {$ccode}.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Sat Oct 26, 2024 4:55 pm    Post subject: Reply with quote

you may have to edit the header files. Looks like the default ones don't work in 7.5 and earlier on 32-bit targets. (64-bit works fine, and next ce version works completely fine as well)

I do recommend not using the includes anyhow as they include unnecessary code when included which will clutter the symboltable. My goto approach is define the function headers I use myself first, so there's no confusion about headers

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
HighVoltage
How do I cheat?
Reputation: 0

Joined: 04 Dec 2023
Posts: 8

PostPosted: Sat Oct 26, 2024 5:10 pm    Post subject: Reply with quote

Dark Byte wrote:
you may have to edit the header files. Looks like the default ones don't work in 7.5 and earlier on 32-bit targets. (64-bit works fine, and next ce version works completely fine as well)

I do recommend not using the includes anyhow as they include unnecessary code when included which will clutter the symboltable. My goto approach is define the function headers I use myself first, so there's no confusion about headers


I am much obliged; thanks for taking the time to track this bug.

In that case, I'll define the headers manually for now as I continue to await the next C.E. release on your Patreon (hopefully soon!)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites