By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

random number generators

P: 5
Hello everybody,
I have these errors on C program that may be because of random number definition. I use an SSH to compile C like in Linux. May be you have idea whether the errors are due to the random number generators in my program do not match those available from libraries in the SSH. My C program uses these libraries
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4. #include<assert.h>
  5. #include<fftw3.h>
  6.  
  7. // These are the definitions of random number generators being used, 
  8.  
  9.  static unsigned long long int x = 1;
  10.  double drand64(void) .......................................................line 1781
  11. {
  12.    x = 6364136223846793005ll * x + (long long int) 1;  
  13.    return (double) x * 5.4210108624275218e-20; 
  14. }
  15. void srand64(int seed).......................................................line 1787
  16. {
  17.    assert(sizeof(long long int) == 8);
  18.    x = seed;
  19. }
  20.  
  21. // The calling functions 
  22.  
  23. srand48(time(NULL));
  24. srand64(time(NULL));........................line 778
  25.  
  26.  r1 = drand48();
  27.  r2 = drand64();................................line 783
  28.  
  29. /* . . . */
  30.  
When I compile using icc, there are several warnings on random number generators

GlobalRevows.c(192): warning #181: argument is incompatible with corresponding format string conversion
sizeof(real), (double) h, MAX, MAX_pass);
^
GlobalRevows.c(778): warning #266: function declared implicitly
srand64(time(NULL));
^
GlobalRevows.c(783): warning #266: function declared implicitly
r2 = drand64();
^
GlobalRevows.c(791): warning #266: function declared implicitly
r2 = drand64();
^
GlobalRevows.c(800): warning #177: label "Next_T" was declared but never referenced
Next_T:
^
GlobalRevows.c(1780): warning #159: declaration is incompatible with previous "drand64" (declared at line 783)
double drand64(void)
^
GlobalRevows.c(1786): warning #159: declaration is incompatible with previous "srand64" (declared at line 778)
void srand64(int seed)
^
GlobalRevows.c(1792): error: variable "x" has already been initialized
static unsigned long long int x = 1;
^
GlobalRevows.c(1800): warning #147: declaration is incompatible with "void srand48(long)" (declared at line 522 of "/usr/include/stdlib.h")
void srand48(int seed)
^
Compiling with gcc gives errors something like this;

GlobalRevows1.c:1781: error: conflicting types for 'drand64'
GlobalRevows1.c:783: error: previous implicit declaration of 'drand64' was here
GlobalRevows1.c:1787: error: conflicting types for 'srand64'
GlobalRevows1.c:778: error: previous implicit declaration of 'srand64' was here
I have tried many alternative ways but none works. Any suggestion would be appreciated.

regards,
Aug 9 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.