Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Randomizing during compilation

Name: Anonymous 2010-02-24 8:01

I want some numbers to differ in every build. How do I do that in c?

Name: Anonymous 2010-02-24 8:05

Why C? Surely you would do that in your build script.

Name: Anonymous 2010-02-24 8:22

>>2
makefiles are bloat

Name: Anonymous 2010-02-24 8:40

>>3
It doesn't have to be, a basic one would be a few lines.Have all the numbers that need to be unique be randomly generated with any random function and pass in the seed as a compile time parameter.

Name: Anonymous 2010-02-24 9:00

Call the /dev/random device somewhere in your compilation script.

Name: Anonymous 2010-02-24 9:11

>>3
No, them aren't, it's quite easy actually.

You do #include </dev/stdin> in your C file and simply append <<< "int rand_const = $$RANDOM;" to the compiler invocation. That is all, no bloat.

Name: Anonymous 2010-02-24 10:39

>>6
LOL EPIC

Name: Anonymous 2010-02-24 11:19

#include </dev/stdin>

I can think of some very creative uses for this.

Name: Anonymous 2010-02-24 11:29

>>6
Haha oh wow.

Name: Anonymous 2010-02-24 11:36

>>6

Whoa, whoa, what? You can do that?

Name: Anonymous 2010-02-24 12:33

>>10
Yes! Pay attention though: double '$' is needed only if you invoke the compiler from a Makefile, if you are compiling from the commandline/script, it's just '$RANDOM'.

Name: Anonymous 2010-02-24 13:25

>>11
DOUBLE DOLLAR MY ANUS

Name: Anonymous 2010-02-24 17:29

MY ANUS IS BLEEDING
For the love of God, MY ANUS IS BLEEDING

Name: Anonymous 2010-02-25 4:51

eval-when

Name: Anonymous 2010-02-25 5:11

[m]
(eval-when (:compile-toplevel)
  (defparameter *magic-value* (random #.(1- (expt 2 32))))
[m]

Name: >>15 2010-02-25 5:17

Of course in C, you would just put the numbers in a header file, and have that header file be generated at build time.

Name: Anonymous 2010-02-25 6:08

>>16
[u][sup]GENERATE[/supmy anus[u]

Name: Anonymous 2010-02-25 6:09

>>16
GENERATEmy anus

MASSIVE BBCODE FIAILURE I FAIL SO BAD KILL MYSELF NOW

Name: Anonymous 2010-02-27 6:58

TRUE ENTERPRISE QUALITY SOFTWARE

Name: Anonymous 2011-02-02 23:33

Name: Anonymous 2011-02-17 20:11

that's cool and all, but check my doubles over there<

Don't change these.
Name: Email:
Entire Thread Thread List