About Store Forum Documentation Contact



Post Reply 
EE Script question
Author Message
Rubeus Offline
Member

Post: #1
EE Script question
So I just started porting my code over to EE Script(2.0), and I've been doing well for the most part. But I am having trouble with 2 issues; I'm hoping those of you more experienced with the EE Script will know what I'm doing wrong... or if it's a 'bug':

1)One file has what is supposed to be a static class. However, even if the class is entirely empty, making "class myClass" into "static class myClass" results in a warning: "...\source\$$forward.h(7); C4091: 'static ' : ingored on left of 'myClass' when no variable is declared". All $$forward.h(created at compile-time by EE, it seems) contains is "static class myClass". It throws this warning 2x for each code file in my project. This can be reproduced by adding 'static' to any class/struct in the tutorials.
Removing 'static' allows it to compile fine, except for...

2) I have trouble reading a file that is basically just a bunch of #define for ajusting various rendering options and settings. If I try to manualy add the .h/.cpp, either nothing happens or I get a ton of redifinition errors in unrelated code. If I put the #define options in the files that call them, they seem to work OK. It appears that the way EE Script is able to make cross-file calls doesn't extend to preprocessor definitions(even in VS), unless I've done something wrong. Is there some way to get around this?

Thanks
04-15-2013 03:44 AM
Find all posts by this user Quote this message in a reply
smashthewindow Offline
Member

Post: #2
RE: EE Script question
1) What exactly do you mean by a static class? "static class" isn't a proper keyword in C++. (And also the compiler error suggests that too). I would suggest using the singleton pattern instead.
04-15-2013 11:38 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #3
RE: EE Script question
Static classes and structs are legal in .net; basically, it just forces you to make everything in that class static, which I wanted. I am in the process of turning it into a singleton, even though it's a lot more work for the same thing.

What really bugs me, though, is the #define issues. What really baffles me is that I have 2 #define at the top in "Main", and in my "StateGame", it recognizes one of them, but not the other. This behavior is the same in Visual Studio.
If I had to guess, I'd say when the code editor turns the code files into CPP/H files, it puts the preprocess stuff in the CPP instead of the .H(although, why I can see some of them still baffles me). Does anyone know a way around this? I could use some const variables instead, I guess...
04-15-2013 05:35 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: EE Script question
1) There's no such thing as static class in C++ and EE Code Editor.

2) Code Editor does not support #define globally in your codes.
You can however:
use the #define only inside body of a single function (though untested)
void name()
{
#define
}

or do all of your #defines in one header stored outside of your EE project (but on the disk, like in "d:/defines.h") and in the application settings, "include headers" option, list there your "d:/defines.h" header
04-17-2013 01:26 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #5
RE: EE Script question
Thanks for the reply. I got things working with a singleton and const variable instead of #define whenever cross file reading was required. I imported my project from EE 1.0 where I the static class worked without even a warning, so I wonder if there was a change recently to C++ to allow it? Regardless, I've worked around it, so it's moot now.
04-17-2013 05:59 PM
Find all posts by this user Quote this message in a reply
para Offline
Member

Post: #6
RE: EE Script question
C++ has no static classes like C# does, only in managed c++ (eww...) there's such a thing.
You can have static members and methods in a class. A class which has all members and methods defined as static is a bit pointless though. And lastly, singletons should rarely be used. (http://stackoverflow.com/questions/86582...it-be-used)
04-17-2013 09:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #7
RE: EE Script question
I am aware of that all that, Para; I needed a single, always-available class. A static worked for my purposes, as does a singleton.
04-18-2013 12:50 AM
Find all posts by this user Quote this message in a reply
Post Reply