[zscript/ExportedNatives] GCC/Clang compiling errors

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

[zscript/ExportedNatives] GCC/Clang compiling errors

Post by Edward-san »

It seems it fails everything:

GCC:

Code: Select all

In file included from /home/edward-san/zdoom/branch/zscript/src/./v_video.h:41:0,
                 from /home/edward-san/zdoom/branch/zscript/src/posix/hardware.h:38,
                 from /home/edward-san/zdoom/branch/zscript/src/posix/sdl/hardware.cpp:39:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:179:134: error: pasting "::" and "Destroy" does not give a valid preprocessing token
  *ptr, args ... arglist) { return static_cast<object *>(ptr)->object::##func(arglist...); }
                                                                     ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:685:2: note: in expansion of macro ‘VMEXPORT_NATIVES_FUNC’
  VMEXPORT_NATIVES_FUNC(Destroy)
  ^~~~~~~~~~~~~~~~~~~~~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h: In member function ‘void DVMObject<T>::Destroy()’:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:3: error: ‘ExportedNatives’ was not declared in this scope
   ExportedNatives<T>::Get()->Destroy<void, T>(this);
   ^~~~~~~~~~~~~~~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:20: error: expected primary-expression before ‘>’ token
   ExportedNatives<T>::Get()->Destroy<void, T>(this);
                    ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:21: error: ‘::Get’ has not been declared
   ExportedNatives<T>::Get()->Destroy<void, T>(this);
                     ^~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:38: error: expected primary-expression before ‘void’
   ExportedNatives<T>::Get()->Destroy<void, T>(this);
                                      ^~~~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h: In member function ‘void DVMObject<T>::Tick()’:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:3: error: ‘ExportedNatives’ was not declared in this scope
   ExportedNatives<T>::Get()->Tick<void, T>(this);
   ^~~~~~~~~~~~~~~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:20: error: expected primary-expression before ‘>’ token
   ExportedNatives<T>::Get()->Tick<void, T>(this);
                    ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:21: error: ‘::Get’ has not been declared
   ExportedNatives<T>::Get()->Tick<void, T>(this);
                     ^~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:35: error: expected primary-expression before ‘void’
   ExportedNatives<T>::Get()->Tick<void, T>(this);
                                   ^~~~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h: In member function ‘AInventory* DVMObject<T>::DropInventory(AInventory*)’:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:10: error: ‘ExportedNatives’ was not declared in this scope
   return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, item);
          ^~~~~~~~~~~~~~~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:27: error: expected primary-expression before ‘>’ token
   return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, item);
                           ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:28: error: ‘::Get’ has not been declared
   return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, item);
                            ^~
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:62: error: expected primary-expression before ‘*’ token
   return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, item);
                                                              ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:63: error: expected primary-expression before ‘,’ token
   return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, item);
                                                               ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:66: error: expected primary-expression before ‘>’ token
   return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, item);
                                                                  ^
Clang:

Code: Select all

In file included from /home/edward-san/zdoom/branch/zscript/src/posix/sdl/hardware.cpp:39:
In file included from /home/edward-san/zdoom/branch/zscript/src/posix/hardware.h:38:
In file included from /home/edward-san/zdoom/branch/zscript/src/./v_video.h:41:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:3: error: use of
      undeclared identifier 'ExportedNatives'
                ExportedNatives<T>::Get()->Destroy<void, T>(this);
                ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:19: error: 'T' does
      not refer to a value
                ExportedNatives<T>::Get()->Destroy<void, T>(this);
                                ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:613:16: note: declared
      here
template<class T>
               ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:30: error: use
      'template' keyword to treat 'Destroy' as a dependent template name
                ExportedNatives<T>::Get()->Destroy<void, T>(this);
                                           ^
                                           template 
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:23: error: no member
      named 'Get' in the global namespace
                ExportedNatives<T>::Get()->Destroy<void, T>(this);
                                  ~~^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:3: error: use of
      undeclared identifier 'ExportedNatives'
                ExportedNatives<T>::Get()->Tick<void, T>(this);
                ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:19: error: 'T' does
      not refer to a value
                ExportedNatives<T>::Get()->Tick<void, T>(this);
                                ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:613:16: note: declared
      here
template<class T>
               ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:30: error: use
      'template' keyword to treat 'Tick' as a dependent template name
                ExportedNatives<T>::Get()->Tick<void, T>(this);
                                           ^
                                           template 
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:653:23: error: no member
      named 'Get' in the global namespace
                ExportedNatives<T>::Get()->Tick<void, T>(this);
                                  ~~^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:10: error: use of
      undeclared identifier 'ExportedNatives'
                return ExportedNatives<T>::Get()->DropInventory<AInvento...
                       ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:26: error: 'T' does
      not refer to a value
                return ExportedNatives<T>::Get()->DropInventory<AInvento...
                                       ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:613:16: note: declared
      here
template<class T>
               ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:30: error: no member
      named 'Get' in the global namespace
                return ExportedNatives<T>::Get()->DropInventory<AInvento...
                                         ~~^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:62: error: expected
      '(' for function-style cast or type construction
  ...return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, i...
                                                     ~~~~~~~~~~ ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:658:63: error: expected
      expression
  ...return ExportedNatives<T>::Get()->DropInventory<AInventory *, T>(this, i...
                                                                 ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:685:2: error: pasting
      formed '::Destroy', an invalid preprocessing token
        VMEXPORT_NATIVES_FUNC(Destroy)
        ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:179:136: note: expanded
      from macro 'VMEXPORT_NATIVES_FUNC'
  ...args ... arglist) { return static_cast<object *>(ptr)->object::##func(ar...
                                                                    ^
14 errors generated.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Edward-san »

I see it's because of using msvc delayed template parsing syntax...

In fact, passing -fdelayed-template-parsing to Clang compiler helps a bit, but not completely:

Code: Select all

In file included from /home/edward-san/zdoom/branch/zscript/src/posix/sdl/hardware.cpp:39:
In file included from /home/edward-san/zdoom/branch/zscript/src/posix/hardware.h:38:
In file included from /home/edward-san/zdoom/branch/zscript/src/./v_video.h:41:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:685:2: error: pasting
      formed '::Destroy', an invalid preprocessing token
        VMEXPORT_NATIVES_FUNC(Destroy)
        ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:179:136: note: expanded
      from macro 'VMEXPORT_NATIVES_FUNC'
  ...args ... arglist) { return static_cast<object *>(ptr)->object::##func(ar...
                                                                    ^
1 error generated.
/home/edward-san/zdoom/branch/zscript/src/posix/sdl/sdlvideo.cpp:82:1: error: 
      pasting formed '_X_CONSTRUCTOR_false(', an invalid preprocessing token
IMPLEMENT_CLASS(SDLFB, false, false, false, false)
^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:205:29: note: expanded
      from macro 'IMPLEMENT_CLASS'
        _X_CONSTRUCTOR_##isabstract##(cls) \
                                   ^
/home/edward-san/zdoom/branch/zscript/src/posix/sdl/sdlvideo.cpp:82:1: error: 
      pasting formed '_X_POINTERS_false(', an invalid preprocessing token
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:206:37: note: expanded
      from macro 'IMPLEMENT_CLASS'
        _IMP_PCLASS(cls, _X_POINTERS_##ptrs##(cls), _X_ABSTRACT_##isabst...
                                           ^
/home/edward-san/zdoom/branch/zscript/src/posix/sdl/sdlvideo.cpp:82:1: error: 
      pasting formed '_X_ABSTRACT_false(', an invalid preprocessing token
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:206:70: note: expanded
      from macro 'IMPLEMENT_CLASS'
        _IMP_PCLASS(cls, _X_POINTERS_##ptrs##(cls), _X_ABSTRACT_##isabstract##(c...
                                                                            ^
/home/edward-san/zdoom/branch/zscript/src/posix/sdl/sdlvideo.cpp:82:1: error: 
      pasting formed '_X_FIELDS_false(', an invalid preprocessing token
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:206:97: note: expanded
      from macro 'IMPLEMENT_CLASS'
  ..._X_ABSTRACT_##isabstract##(cls), _X_FIELDS_##fields##(cls), _X_VMEXPORT_...
                                                        ^
/home/edward-san/zdoom/branch/zscript/src/posix/sdl/sdlvideo.cpp:82:1: error: 
      pasting formed '_X_VMEXPORT_false(', an invalid preprocessing token
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:206:128: note: expanded
      from macro 'IMPLEMENT_CLASS'
  ..._X_FIELDS_##fields##(cls), _X_VMEXPORT_##vmexport##(cls)) 
                                                      ^
In file included from /home/edward-san/zdoom/branch/zscript/src/dobject.cpp:39:
In file included from /home/edward-san/zdoom/branch/zscript/src/./actor.h:30:
In file included from /home/edward-san/zdoom/branch/zscript/src/./dthinker.h:38:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:624:4: error: use of
      undeclared identifier 'atterm'
                        atterm([]{ delete[] DVMObject<T>::RegistrationIn...
                        ^
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:666:16: note: in
      instantiation of member function 'DVMObject<DObject>::FormatClassName'
      requested here
        DVMObject<T>::FormatClassName(),
                      ^
/home/edward-san/zdoom/branch/zscript/src/dobject.cpp:63:23: note: in
      instantiation of static data member 'DVMObject<DObject>::RegistrationInfo'
      requested here
        &DVMObject<DObject>::RegistrationInfo,  // VMExport
                             ^
In file included from /home/edward-san/zdoom/branch/zscript/src/dobject.cpp:39:
In file included from /home/edward-san/zdoom/branch/zscript/src/./actor.h:30:
In file included from /home/edward-san/zdoom/branch/zscript/src/./dthinker.h:38:
/home/edward-san/zdoom/branch/zscript/src/./dobject.h:648:30: error: use
      'template' keyword to treat 'Destroy' as a dependent template name
                ExportedNatives<T>::Get()->Destroy<void, T>(this);
                                           ^
                                           template 
2 errors generated.
Still, that's not good for GCC.
Last edited by Edward-san on Thu Nov 10, 2016 5:34 am, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Graf Zahl »

Well, I wasn't convinced about that stuff anyway, so maybe I'll just delete it again.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Edward-san »

Let's wait for Leonard2's reply first.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Graf Zahl »

I wasn't sold on this stuff anyway. But if it needs to be hacked to pieces to compile, even less.
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Leonard2 »

I didn't intend for this to be pushed right away anyways.
I knew this was going to be the first thing that comes up: compilers complaining about obscure msvc "fancy features".
This is so annoying. Is there any way to disable all those msvc "features" completely?
All they do is get in the way of collaborations.
I believe I can fix the issues here but someone will have to tell me first how I can disable the compiler-specific features.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Graf Zahl »

Sorry, no idea. I don't even know what precisely here triggers the compile errors.
User avatar
Rachael
Posts: 13954
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Rachael »

I am curious, where did these commits come from? They suddenly just appeared and I see no pull request on them and I haven't been able to find a discussion link on them.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Graf Zahl »

I pulled them directly from Leonard's repository. We discussed this via PM.
User avatar
Rachael
Posts: 13954
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Rachael »

It would've really been nice for some of this to be done in the open. For example, I've been really curious about the IMPLEMENT_CLASS macro change. And those other commits, too. What possibilities does this open up? I can't make any guess based on the commit messages alone.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Graf Zahl »

There was an exchange of two PM's. He first told me that he had an idea and the second contained the link to this stuff.
The idea was to implement virtual script functions without having to rename the internal ones because to work from a script it needs a two-stage approach: One wrapper around the script call and the native implementation.
But right now I don't really know if this method is actually doing what I need, for each native class it creates a child class which contains the wrappers for the script calls, but since they have the same name as the actual virtual function it makes it a lot more complicated to call the native version from the script. And with the above compile problems it makes it even less interesting. It's surely interesting what he did here but I think I'll pass. The only part I will definitely keep in is the IMPLEMENT_CLASS stuff because it removes a lot of macro madness.
User avatar
Rachael
Posts: 13954
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Rachael »

Ah, okay. Thank you!
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Leonard2 »

Graf Zahl wrote:but since they have the same name as the actual virtual function
That's needed so that any call of said method in the native code will map to the scripted function automatically.
That's what the problem was when you posted about it in the zscript discussion thread (with your Destroy example).
Graf Zahl wrote:it makes it a lot more complicated to call the native version from the script.
I think I get what you mean now (I was unsure when reading your PM) but I don't really see how this complicates things?
Calling Super::method from zscript is no big deal at all, if said method is native then you can be sure that the first parent will be the "hook" class therefore calling the wanted method is as simple as calling the template parent's method.
On top of that the needed information about this is already here: the wrapper class's parent stores a pointer to said class (the VMExport pointer) and more could easily be added.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Graf Zahl »

Leonard2 wrote:therefore calling the wanted method is as simple as calling the template parent's method.
That's obvious, but if the script hook of the template class wasn't there I could just call into the native virtual method table, only requiring one version of the function in the lowest class that defines it, not one for every class that has a native parent.
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: [zscript/ExportedNatives] GCC/Clang compiling errors

Post by Leonard2 »

Graf Zahl wrote:That's obvious, but if the script hook of the template class wasn't there I could just call into the native virtual method table, only requiring one version of the function in the lowest class that defines it, not one for every class that has a native parent.
Oh I see now.
So I'm assuming you're talking about these:

Code: Select all

DEFINE_ACTION_FUNCTION(DObject, Destroy)
{
	PARAM_SELF_PROLOGUE(DObject);
	self->Destroy();
	return 0;	
}
since those are the only thing that allow to make native method calls from zscript.
You don't really need multiple versions.
Since this will only ever be reached by zscript calls, we can safely assume that it is an attempt to call the native method that was inherited (and not overriden) because if it was overriden then this would not be called in the first place as the CALL VMOP in question would use the proper pointer.
So knowing this and knowing that this is the only place where the problem occurs, the solution is simple:
In dobject.h:

Code: Select all

class DObject
{
	bool SuperCall;

public:
	void VMSuperCall() { SuperCall = true; }
}

class DVMObject
{
public:
	virtual void Destroy()
	{
		if (SuperCall)
		{
			SuperCall = false;
			<use the special syntax that I already made>;
		}
		else
			<do the usual routine of checking for script definitions>;
	}
}
Then in the native export definition:

Code: Select all

DEFINE_ACTION_FUNCTION(DObject, Destroy)
{
	PARAM_SELF_PROLOGUE(DObject);
	self->VMSuperCall();
	self->Destroy();
	return 0;	
}
Was that what you wanted/asked?
Post Reply

Return to “Closed Bugs [GZDoom]”