473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

What's wrong with this macro?

Is there anything wrong with this macro?

#define randint(a,b) (a)+(((b)-(a)+1)*(float)rand()/RAND_MAX)

If I do randint(10, 0x10000) in a loop it sporatically generates:

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()

with no backtrace and I compiled with debugging symbols. Could this be
a bug in gcc?

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)
Nov 14 '05 #1
1 1071
On Wed, 01 Sep 2004 03:00:23 -0400, Michael B Allen wrote:
Is there anything wrong with this macro?

#define randint(a,b) (a)+(((b)-(a)+1)*(float)rand()/RAND_MAX)

If I do randint(10, 0x10000) in a loop it sporatically generates:

Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? ()


Never mind. The bug is mine. Of course.

Mike
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
4
by: Martin Magnusson | last post by:
I'm using a matrix and vector library, that won't compile. When running g++ I get the error message "macro "minor" passed 5 arguments, but takes just 1" The definition of "minor" looks like...
8
by: sandwich_eater | last post by:
I get compiler error "cerr undeclared first use this function." #define err_ret(e) cerr << e; return -1 .... err_ret("who ate my muffy?");
7
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead....
23
by: yezi | last post by:
Hi, all: The 1st sendtence: int main(){ char string={""}; string = {" connected "}; ..... }
38
by: DaVinci | last post by:
#include<stdio.h> #include<stdlib.h> #include<string.h> #define SECONDS_PER_YEAR (60*60*24*365)UL int main() { unsigned long int u_i = SECONDS_PER_YEAR; printf("%lu\n",u_i);
14
by: raghu | last post by:
Hello I have a doubt plz clarify that #ifndef SYSTEM_H #define SYSTEM_H what will be the value of SYATEM_H after this #define statement and before that statement. Thanking you all Bye
4
by: Gestorm | last post by:
Hi all, I found a macro "USE_VAR" in the code of bash-3.2 as follows: /*file: bash-3.2/shell.c*/ 344 USE_VAR(argc); 345 USE_VAR(argv); 346 USE_VAR(env); 347 USE_VAR(code); 348 ...
31
by: Tommy | last post by:
struct stat *stats IF_LINT (= 0); I don't know why "IF_LINT (= 0)" is needed ? Source is df.c of df program on Linux coreutils-5.2.1\coreutils-5.2.1\src Thanks!
32
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.