[Solved] Using ULL suffix in C++ code compiled on RHEL6.4

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat [Solved] Using ULL suffix in C++ code compiled on RHEL6.4
# 1  
Old 02-25-2014
[Solved] Using ULL suffix in C++ code compiled on RHEL6.4

Hi,

I am trying to compile a piece of c++ code using the g++ compiler on an RHEL6.4 system. Here is a code snippet:

Code:
#define CDMA_TIME_OFFSET     315964800000ULL
unsigned long long int ABC=CDMA_TIME_OFFSET;

For some reason, the value assigned to ABC is only the LSB 32-bit of CDMA_TIME_OFFSET. The MSB 32-bit is being ignored.

Below are the relevant compiler options that I am using:

Code:
./x86_64-redhat-linux-gnu-g++ -c -g -pthread -lpthread -m32 -O3 -fno-strict-aliasing -ffast-math -fno-trapping-math -std=c99

Note that I have already tried including the -std=c99 option but that did not help. Could the -m32 that I have used be the reason for MSB 32-bit being ignored?

Thanks !
# 2  
Old 02-25-2014
Without -m32, 'unsigned long long' may not be valid at all.

How are you checking whether the upper 32 bits have been discarded? Your code works perfectly fine here, I suspect the way you're printing them is truncating it. This is how I print it:

Code:
printf("%qd\n", ABC);

# 3  
Old 03-07-2014
I rechecked my code and realized that some place I was typecasting the ULL value with an "unsinged". It seems this was causing the value to be truncated to a 32-bit number:

Code:
unsigned long long int ABC=(unsigned)CDMA_TIME_OFFSET;

After removing the "unsigned" typecasting, the values are coming good.

Thanks!
This User Gave Thanks to ankit_ka For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Help understanding this code!!

Hi guys, I am still learning awk and much apprecated to shed some light on the following: the questions asked is below! { total = i = 0 do { ++i total += $i } while ( total <= 100 ) print i, ":", total } File used: cat test.do 45 25 60 20 10 105 50 40 33 5 9 67 108 3 5 4 (2 Replies)
Discussion started by: Apollo
2 Replies

2. Shell Programming and Scripting

[solved] awk: return code from system() always 0 ??

Hi all, I currently have the following problem: In an awk script, I am calling a predifend function from the END{} and handing over a command string. This string arrives flawless and is executed like this: function send_msg( cmd_str ) { ... (7 Replies)
Discussion started by: zaxxon
7 Replies

3. UNIX for Advanced & Expert Users

[SOLVED] Code does not run when assigned to a variable

I am more of a newbie, but wanted to post this in this forum as I was afraid no one would look at it in unix forums as it concerns shell scripting. I have a shell script that now runs fine with the exclusion of one line: x=`su nbadmin -c "ssh -t servery /usr/openv/netbackup/bin/bplist -C... (7 Replies)
Discussion started by: newbie2010
7 Replies

4. UNIX for Dummies Questions & Answers

[Solved] How to refer to input file in code?

This may be a dumb question, but googling is not giving me an answer. I'm trying to figure out how to refer to an input file in my code. Lets say i run a script in bash: "sh shellscript.sh inputfile" (Inputfile will be variable...whatever file i run the script on) I wanted to make... (5 Replies)
Discussion started by: legato22
5 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Why code run not correctly

Hi there can anyone help me here is my code echo "Type in a positive number" read X I=2 while do if then echo "It is not prime" break else if then echo "It is prime" break else I=$(( $I + 1)) fi fi (4 Replies)
Discussion started by: FUTURE_EINSTEIN
4 Replies

6. Shell Programming and Scripting

[Solved] problem - connecting code with external file

hello. this is the code #!/bin/sh total1024=0 total2048=0 total8192=0 if ; then if ; then while read variable do if ; then total1024=$(( $total1024 + 1 )) fi if ; then total2048=$((... (4 Replies)
Discussion started by: Telis
4 Replies

7. OS X (Apple)

[Solved] Running shell code in AppleScript without Terminal

What I want my script to do is to run a command in Terminal and close that same Terminal window when the process is complete. Of course I could ad a delay of 6 seconds to complete the process, but it may not be enough every time. To simplify my question, this is what I want to achieve.... (9 Replies)
Discussion started by: ShadowofLight
9 Replies

8. Shell Programming and Scripting

Arguments and suffix name

While calling shell script i need to use prefix . Any idea? Ex: myscript.sh -parameter1 "AA;BB" -parameter2 "DD;E" (5 Replies)
Discussion started by: mnjx
5 Replies

9. Solaris

Symbol reference error for same code & libraries but compiled in different environmen

Hi All, I am having a code written in C++.First I build this code on SUN 5.10.It was built successfully.Following is the log when build was successful. -L/apps/compilers/SUNWspro/lib -lm -lsunmath \ -o App ld: warning: symbol `clog' has differing types: (file... (0 Replies)
Discussion started by: milindb
0 Replies

10. Programming

Why my code couldn't be compiled

#include <Xm/Xm.h> #include <Xm/PushB.h> Widget CreatePushbutton(Widget parent, char* name, XtCallbackProc callback, XtPointer client_data) { Widget push; Arg args; Cardinal n; n=0; push=XmCreatePushButton(parent, name, args, n); XtAddCallback(push,... (4 Replies)
Discussion started by: endeavour1985
4 Replies
Login or Register to Ask a Question