Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown type found [long] #216

Open
obiwanjacobi opened this issue Sep 29, 2021 · 4 comments
Open

Unknown type found [long] #216

obiwanjacobi opened this issue Sep 29, 2021 · 4 comments

Comments

@obiwanjacobi
Copy link

Noob here.

I get this error:
CppStruct [PFactoryInfo]/long flags error : Unknown type found [long]

and have tried several things to fix it but to no avail... I suspect the FactoryFlags are the problem (see source code below).
(I have trouble deciphering the docs on where these xml tags go precisely. Sometimes it is mentioned but not always. No errors when you do it wrong too.)

Can anybody shed some light on this?


The mapping file:

        <assembly>SharpGenToolsTest</assembly>
	<namespace>SharpGenToolsTest.Interfaces</namespace>
	<depends>SharpGen.Runtime</depends>

        <sdk name="StdLib" />
	<sdk name="WindowsSdk" />

        <include-dir .... />

        <include file="ipluginbase.h" namespace="SharpGenToolsTest.Interfaces">
		<attach>IPluginBase</attach>
		<attach>PFactoryInfo</attach>
		<attach>PClassInfo</attach>
		<attach>IPluginFactory</attach>
		<attach>PClassInfo2</attach>
		<attach>IPluginFactory2</attach>
		<attach>PClassInfoW</attach>
		<attach>IPluginFactory3</attach>
	</include>

Source code:

struct PFactoryInfo
{
	enum FactoryFlags
	{
		kNoFlags = 0,
		kClassesDiscardable = 1 << 0,	
		kLicenseCheck = 1 << 1,	
		kComponentNonDiscardable = 1 << 3,	
		kUnicode = 1 << 4
	};

	enum
	{
		kURLSize = 256,
		kEmailSize = 128,
		kNameSize = 64
	};

	char8 vendor[kNameSize];
	char8 url[kURLSize];
	char8 email[kEmailSize];
	int32 flags;
};
@obiwanjacobi
Copy link
Author

Looks like some missing bindings?

Adding this to the mapping file fixes it:

<bindings>
	<bind from="long" to="System.Int32" />
	<bind from="unsigned long" to="System.UInt32" />
</bindings>

(Onto new errors...)

@jkoritzinsky
Copy link
Member

Long in C maps to either Int32 or IntPtr depending if the sourcs are compiled on Windows or non-Windows. I believe we have a NativeLong and NativeULong type in 2.0 that we map to instead to ensure correct behavior on all platforms.

@andrew-boyarshin
Copy link
Contributor

@jkoritzinsky yeah, long should've resolved to SharpGen.Runtime.NativeLong. It looks like it didn't, as if SharpGen.Runtime is not referenced.

@rayzorben
Copy link

I am getting the same issue, I used NuGet and added both SharpGen.SDK and SharpGen.Runtime.

If I add

<bindings>
    <bind from="long" to="System.Int32" />
    <bind from="HWND__" to="System.IntPtr" />
  </bindings>

It works and generates the code. But without it it fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants