Click here to Skip to main content
15,886,806 members

Comments by Ghosuwa Wogomon (Top 10 by date)

Ghosuwa Wogomon 26-Nov-13 12:05pm View    
Deleted
Typedefs work no differently in C++ than they do in C. The typedef isn't the problem. Like I said in the post, GCC is saying there are 3

Keyword: 3
Again: 3
For Extra Measure: 3
Not: 2
There are: 3

Definitions of Engine_Module. I posted all of my code here and I know the first two are the typedef and the Engine_Module struct, but nowhere does my code define a third instance of Engine_Module. It's safe to assume g++ is using the name Engine_Module for the Engine::Module class. I was simply asking if there was a way to get around the ambiguity without changing the name.

Answering my own question though, I found out there isn't. C++ users will just have to use the class Engine::Module.
Ghosuwa Wogomon 23-Nov-13 15:28pm View    
I would like to know why I as the person who asked this question cannot respond to or decline the solution of the person who posted the solution to my problem. Their answer is 100% incorrect and the user obviously has no experience with C.

typedef's are required for structs in C. A typedef with the same name as a type will not cause errors in C or C++, I have used them for years and they were designed specifically for that purpose until C++ made the struct and enum keywords optional for declarations. The this keyword is only reserved for functions that use the thiscall calling convention which is in fact nothing more than passing a hidden argument called 'this' on the stack that points to the class. Replicating C++ class functionality was the entire idea.
Ghosuwa Wogomon 23-Nov-13 15:04pm View    
Like I said, I defined 2 definitions; a typedef and a struct. GCC is saying there's <3>. And no, it's not nonsense. It's the standard way of defining a new struct type that isn't anonymous. In C, a definition like:

struct MyType
{
};

has to be declared

struct MyType mt;

In C++, they remove this requirement so you can just type

MyType mt;

But for C you have to declare a type definition that overrides it. I prefer to declare structures this way because they're easier to document, I like GNU style block indentation, and I can do things you can't do with an anonymous definition like:

struct MyType
{
struct MyType *parent;
};
Ghosuwa Wogomon 23-Nov-13 14:59pm View    
I probably mistyped it when I was writing the brief version for the question, but it's actually

typedef struct Engine_Module Engine_Module;
Ghosuwa Wogomon 20-Nov-13 12:30pm View    
Why do you assume I haven't? There is only 1 definition of the Engine_Module struct and it's typedef in my code. When compiled as C code there are no problems whatsoever. When compiled as C++ code, there an additional definition. The only thing defined in the C++ code is the Engine namespace and the Module class.

Since using "struct Engine_Module" specifically does not solve the issue, then both definitions are structs, which means GCC is creating a second Engine_Module struct under the table without my code.