Windows header translation issue for Array values

Windows specific questions.
Post Reply
stephanbrunker
Posts: 62
Joined: Nov 02, 2013 14:57

Windows header translation issue for Array values

Post by stephanbrunker »

I found an issue in the windows headers for types consisting an array and the pre-defined values for these types.

For example (winnt.bi):

Code: Select all

type _SID_IDENTIFIER_AUTHORITY
	Value(0 to 5) as UBYTE
end type

#define SECURITY_NT_AUTHORITY (0, 0, 0, 0, 0, 5)
I cannot see a way to assign the pre-defined value to the type normally. If the () brackets in the #define are have additional {} brackets, then you can assign it normally:

Code: Select all

#define SECURITY_NT_AUTHORITY ({0, 0, 0, 0, 0, 5})
Dim exampleSID as  _SID_IDENTIFIER_AUTHORITY = SECURITY_NT_AUTHORITY
The automatic translator should be edited to correct that for future releases. I'll put a manually edited winnt.bi at my git: https://github.com/stephanbrunker/fbc_105_patch
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Windows header translation issue for Array values

Post by dkl »

The problem should be solved for SECURITY_NT_AUTHORITY and some others in Git, see commit winapi: Fix winnt.h SECURITY_*_AUTHORITY initializers.

That's one of the issues I couldn't figure out when working on fbfrog. The problem is that a C initializer like {1, 2} works with struct or array, but in FB they have a separate syntax: (1, 2) for struct and {1, 2} for array. So currently fbfrog defaults to the struct translation, and if that's wrong, it needs to be given extra context information. It would probably be better to change that to produce a TODO instead of silently incorrect translation...
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Windows header translation issue for Array values

Post by MrSwiss »

@stephanbrunker,

IMHO this sort of post, nothing directly, to do with Libraries and, only specific to Windows, should be located:
Platforms-Windows ...
stephanbrunker
Posts: 62
Joined: Nov 02, 2013 14:57

Re: Windows header translation issue for Array values

Post by stephanbrunker »

@MrSwiss: OK, I'll put the next one at the Windows section.

@dkl: I tried different sytaxes, and the only working one was with the combined brackets, because it's in an array inside a type. I don't know if there are other objects the initalizers have to fit into, but that would be an array direct with DIM array(0 to 5) = Initializer and not an type, so I don't think so. In the related C examples, it is assigned directly without brackets, e.g. the FB version should have both?
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Windows header translation issue for Array values

Post by MrSwiss »

@stephanbrunker,

If you want to test the latest fixes, made to the compiler, try the DEV-ver. 1.06.0 at:
daily-builds (by St_W), at freebasic-portal.de
Post Reply