View Single Post
  #12   Spotlight this post!  
Unread 06-02-2009, 18:01
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Understanding the Source code

Quote:
How have you been using the preprocessor to handle defines? It's more conventional (from the C++ standpoint) to use the "const" keyword.
i use enum { Var1, Var2}; and const float speed=1; but just at the top or near the top #define VAR_NAME 1(Optional value)
also
Quote:
#ifdef WPI_STATUS_DEFINE_STRINGS
#define S(label, offset, message) const int wpi_v_##label = offset; const char *wpi_s_##label = message ;
#else
#define S(label, offset, message) const int wpi_v_##label = offset; extern const char *wpi_s_##label;
#endif
a file may be included more than once (weird, i know, but that is the way the C++ compiler works) so the compiler sees:
Code:
if i have not defined "WPI_STATUS_DEFINE_STRINGS" then
{
  replace the macro "S(label, offset, message)" with
  {
    const int wpi_v_##label = offset;
    const char *wpi_s_##label = message ;
   }
}
else (if i have defined "WPI_STATUS_DEFINE_STRINGS")
{
  replace the macro "S(label, offset, message)" with
  {
    const int wpi_v_##label = offset;
    extern const char *wpi_s_##label;
  }
}
Got it? (I like medium level languages that are safer like C# or (ick!)VB!)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote