LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-05-2005, 05:30 AM   #1
mohtashami
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Rep: Reputation: 0
Question problem with int64 in rh fdeora 4 ...


Hi ALL.
I have a problem in call reference with int64 (in redhat fedora core 4 with gcc 4.0).
see this simple code:

//test1.c -->
#include <stdio.h>
#define ull unsigned long long int

void foo(ull a){
printf("a= %llx\n",a);
}
int main(void){
ull a=0x123456789abcde;
foo(a);
return 0;
}
//test1.c <--


this code is compiled with this warning :
test.c: In function ‘main’:
test.c:8: warning: integer constant is too large for ‘long’ type

but output file executes with correct output.



but see this code
//test2.c -->
#include <stdio.h>
#define ull unsigned long long int
void foo(ull& a){ //changed to call by reference
printf("a= %llx\n",a);
}
int main(void){
ull a=0x123456789abcde;
foo(a);
return 0;
}
//test2.c <--

this code generates this errors :

test.c:4: error: syntax error before ‘&’ token
test.c: In function ‘foo’:
test.c:5: error: ‘a’ undeclared (first use in this function)
test.c:5: error: (Each undeclared identifier is reported only once
test.c:5: error: for each function it appears in.)
test.c: In function ‘main’:
test.c:8: warning: integer constant is too large for ‘long’ type

I want to use an unsigned int 64 with call reference.this code has no error with redhat 7.3 (gcc 2.96).
please help me ....

Last edited by mohtashami; 11-06-2005 at 01:37 AM.
 
Old 11-05-2005, 06:00 AM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
It works if you put "ull" or "ULL" (for unsigned long long) at the end of the constant.
 
Old 11-05-2005, 06:41 AM   #3
mohtashami
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Original Poster
Rep: Reputation: 0
qoute -->
It works if you put "ull" or "ULL" (for unsigned long long) at the end of the constant.
<-- unqoute

the warning is not my problem !
my problem is error in second code.
 
Old 11-05-2005, 07:05 AM   #4
mohtashami
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Original Poster
Rep: Reputation: 0
By adding 'll' to end of definition of a, first code compiles with no warning but second code has error.

Last edited by mohtashami; 11-05-2005 at 07:09 AM.
 
Old 11-05-2005, 05:26 PM   #5
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Oh yeah, I'm sorry.

There are no references in C. They are only available in C++. It's equivalent to using pointers like this:
Code:
#include <stdio.h>
#define ull unsigned long long int
void foo(ull* a){ //changed to call by reference
printf("a= %llx\n",*a);
}
int main(void){
ull a=0x123456789abcdeull;
foo(&a);
return 0;
}

Last edited by spooon; 11-05-2005 at 05:28 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Things a Noob should do first after Fdeora install Frank_Drebin Fedora 38 05-08-2004 09:07 PM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration