Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
POKEMAN SAM
Jul 8, 2004

nielsm posted:

Yeah, the runtime library might very well have thread-local random generator seeds.
If you want fully portable behaviour you're probably better off writing a random generator of your own. (It doesn't need to take more than 10 lines of code for a simple linear congruential one.)

By the way, MSVC's random number generator seeds are in thread-local storage; just an FYI.

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

Gordon Cole posted:

I've got a homework assignment that's driving me nuts. I'm implementing a compiler for a custom language that translates to C. This language supports nested functions that can reference variables in their parent functions. From what I understand, the best way to implement this is to pass a static link (a pointer to the stack frame of the enclosing function) to each function, from which you can find the variable you want by applying a constant offset.

Just figure out which variables from the parent function are being used in the nested function and pass references/pointers to all of them when calling the nested function.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply