Pages: [1]
  Print  
Author Topic: Uninitialised variables  (Read 933 times)
Offline (Male) polygone
Posted on: January 25, 2011, 08:20:59 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 809

View Profile
Uninitialised variables seem to always be treated as 0 instead of throwing an error for me. Intended for now?

Note this is quite a bitch for debugging sometimes.


Tracker Reference:
http://enigma-dev.org/tracker/ticket.php?id=90
« Last Edit: March 05, 2011, 10:57:47 AM by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: January 25, 2011, 08:37:43 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2946

View Profile Email
Yes. I'm still deliberating on how to store object files for multiple settings. You're probably enjoying a two second compile time, yes? That will go up in smoke every time you switch to a GMK with different settings if I don't do something to store objects for each configuration.
It's definitely going to involve some Make and YAML hackery.

I guess, instead, I could do my best to keep setting-dependent code in separate functions or variables in a single source, then have the systems use those.... We'll see. This method would be less efficient, but it shouldn't be that noticeable, and when you went to compile the final product, we could pass the settings in as macros to the sources in question. Thus, we'd have something like this:

Code: (C) [Select]
// For erroring on undefined vars
struct var
{
...
  #if !defined OPT_UNIV_ERROR_UNDEFINED || OPT_UNIV_ERROR_UNDEFINED
    bool initialized;
  #endif
...
  variant &operator* ()
  ...
    #if !defined OPT_UNIV_ERROR_UNDEFINED || OPT_UNIV_ERROR_UNDEFINED
      if (!initialized) show_error("Variable not defined"); // I'll probably use some C++ trickery to resolve the name
    #endif
...
  var():
  #if !defined OPT_UNIV_ERROR_UNDEFINED || OPT_UNIV_ERROR_UNDEFINED
   initialized(false),
  #endif
...

// It will be the responsibility of IsmAvatar to ensure !(!OPT_UNIV_SHOW_ERRORS && OPT_UNIV_ERROR_UNDEFINED)
// But I'll probably double check it and not error

void show_error(...)
{
  #if !defined OPT_UNIV_SHOW_ERRORS || OPT_UNIV_SHOW_ERRORS
    #if !defined OPT_UNIV_ERROR_FATAL || !OPT_UNIV_ERROR_FATAL
      if (MessageBox(enigma::hWnd, ...) == ID_ABORT)
        exit(0);
    #else
      MessageBox(enigma::hWnd, ...);
      exit(0);
    #endif
  #endif
}
« Last Edit: January 25, 2011, 09:08:45 AM by Josh @ Dreamland. » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: [1]
  Print