Randomizing during compilation
1
Name:
Anonymous
2010-02-24 8:01
I want some numbers to differ in every build. How do I do that in c?
2
Name:
Anonymous
2010-02-24 8:05
Why C? Surely you would do that in your build script.
3
Name:
Anonymous
2010-02-24 8:22
4
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.
5
Name:
Anonymous
2010-02-24 9:00
Call the /dev/random device somewhere in your compilation script.
6
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.
7
Name:
Anonymous
2010-02-24 10:39
8
Name:
Anonymous
2010-02-24 11:19
#include </dev/stdin>
I can think of some very creative uses for this.
9
Name:
Anonymous
2010-02-24 11:29
10
Name:
Anonymous
2010-02-24 11:36
>>6
Whoa, whoa, what? You can do that?
11
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'.
12
Name:
Anonymous
2010-02-24 13:25
>>11
DOUBLE DOLLAR MY ANUS
13
Name:
Anonymous
2010-02-24 17:29
MY ANUS IS BLEEDING
For the love of God, MY ANUS IS BLEEDING
14
Name:
Anonymous
2010-02-25 4:51
eval-when
15
Name:
Anonymous
2010-02-25 5:11
[m]
(eval-when (:compile-toplevel)
(defparameter *magic-value* (random #.(1- (expt 2 32))))
[m]
16
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.
17
Name:
Anonymous
2010-02-25 6:08
>>16
[u] [sup] GENERATE[/sup
my anus [u]
18
Name:
Anonymous
2010-02-25 6:09
>>16
GENERATE my anus
MASSIVE BBCODE FIAILURE I FAIL SO BAD
KILL MYSELF NOW
19
Name:
Anonymous
2010-02-27 6:58
TRUE ENTERPRISE QUALITY SOFTWARE
21
Name:
Anonymous
2011-02-02 23:33
22
Name:
Anonymous
2011-02-17 20:11
that's cool and all, but check my doubles over there