Jump to content
The Dark Mod Forums

Uninitialized members and Typeinfo


duzenko

Recommended Posts

1 hour ago, duzenko said:

@stgatilovCan we fix typeinfo? How do we point it to the right path for this .hpp?

image.png.7d4a24161c79e1a6f3fbf1f43316c8e9.png

Well, in principle we can.
There is some macro which is defined only by typeinfo compiler, and we can ifdef by it.
Of course, typeinfo cannot and should not parse third-party libs.

However, the first question is: what are you trying to achieve? 🤔

Link to comment
Share on other sites

26 minutes ago, stgatilov said:

However, the first question is: what are you trying to achieve? 🤔

Sorry, I should have started with that

I'm puzzled by these warnings in the xray test map. I'd like to see if the typeinfo lib could be used to debug this

image.thumb.png.54d62fe15c4c55d1f50d83b355ee34b1.png

  • Like 1
Link to comment
Share on other sites

11 minutes ago, duzenko said:

Sorry, I should have started with that

I'm puzzled by these warnings in the xray test map. I'd like to see if the typeinfo lib could be used to debug this

Oh yeah, that's not good...

Yes, you can use typeinfo lib to see member names, but it will by no means be easy. You will have to surround bad includes with #ifdef smth, replace all #pragma once with old-style include guard, do something with override (e.g. add #define override {empty} as predefined macro under typeinfo), add private: if some members are implicitly private... that's what I remember. 😥

A somewhat cumbersome approach but easier to boot would be to put breakpoint to where this message is printed, then find manually in the debugger which member this offset corresponds to. I.e. binary search by class members in their order... maybe using offsetof macro (if debugger supports it).

Link to comment
Share on other sites

1 minute ago, stgatilov said:

 

A somewhat cumbersome approach but easier to boot would be to put breakpoint to where this message is printed, then find manually in the debugger which member this offset corresponds to. I.e. binary search by class members in their order... maybe using offsetof macro (if debugger supports it).

Umm... can it be automated by something like

for(auto& property: typeinfo::getPropertiesFor(this)) {

     if (offsetof(property) == missingPropOffset) {
		...
     }

}
Quote

Oh yeah, that's not good...

Yes, you can use typeinfo lib to see member names, but it will by no means by easy. You will have to surround bad includes with #ifdef smth, replace all #pragma once with old-style include guard, do something with override (e.g. add #define override {empty} as predefined macro under typeinfo), add private: if some members are implicitly private... that's what I remember. 😥

Sounds like a PhD course work :D

Link to comment
Share on other sites

11 minutes ago, duzenko said:

Umm... can it be automated by something like

for(auto& property: typeinfo::getPropertiesFor(this)) {

     if (offsetof(property) == missingPropOffset) {
		...
     }

}

Yes, if you have static reflection.
Did reflection got into C++20 already? 🤔😭

Quote

Sounds like a PhD course work :D

Yeah, it is a lot of fun, but only if you really looking for this kind of fun 😁

Link to comment
Share on other sites

2 minutes ago, stgatilov said:

Yes, if you have static reflection.
Did reflection got into C++20 already? 🤔😭

What about our "basic" RTTI? Isn't that separate to typeinfo.lib? I am completely clueless, but the wiki says typeinfo.lib is only needed for memory logs, which kinda implies RTTI is something different?

Link to comment
Share on other sites

7 hours ago, duzenko said:

What about our "basic" RTTI? Isn't that separate to typeinfo.lib? I am completely clueless, but the wiki says typeinfo.lib is only needed for memory logs, which kinda implies RTTI is something different?

The warnings that you look at are the memory log. Typeinfo is needed to associate member names to offsets.
The C++ RTTI only includes class names, inheritances, virtual methods (see reference).

Link to comment
Share on other sites

Another attempt at running typeinfo.exe

Fails with

Type Info Generator v1.0 (c) 2004 id Software
../darkmod_src/game
processing 'C:\Users\a\Documents\tdm\darkmod\..\darkmod_src\game\gamesys\TypeInfo_GenHelper.cpp' for type info...
ERROR: file ../darkmod_src/idlib\sys/sys_defines.h, line 148: #error without string

at this line

image.png.56b89b61721aa15be80da4aead7d5471.png

It does not matter if I define WIN32 in generator's own define list. It seems that it always executes compiler directives, even if they are disabled by an outer ifdef. Is typeinfo so hopelessly broken it cannot be used without major overhaul?

Link to comment
Share on other sites

8 hours ago, duzenko said:

You mean you were able to run it locally with a bunch of changes but never commited those changes to svn?

No, I committed all the changes to SVN at that time.
But typeinfo parser is very fragile. I'm sure it quickly broke after that due to normal development.

  • Like 1
Link to comment
Share on other sites

1 hour ago, stgatilov said:

Anyway, the generated typeinfo is wrong.

If you try to compile TDM with it, you'll get a lot of errors.
Most of the are due to not understanding C++11, and it is not wise to eradicate C++11 from headers or trying to #ifdef every little thing.

I have put a few more fixes and cut some corners

Revision 9713 seems to work

image.thumb.png.81524662edb9e0c04531cb24b4b0c6a4.pngI am particularly puzzled about the define private public trick, that I had to disable to make the modern compiler happy.

Link to comment
Share on other sites

It seems that all "uninitialized members" are in fact paddings added for complex members like structs or template parameters

It's easy enough to filter when dealing with simple types, but templates aren't supported by TypeInfo and will have to be assumed always ok.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 3 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...