473,399 Members | 3,832 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,399 software developers and data experts.

AMD opteron 64

Hello,

I have a test program that is compiled fine on a 32 bits redhat linux using gcc :
***********************
main (argc, argv)
int argc;
char *argv[];
{
int *ka;
int nka;

/* allocation dynamique entiere */
ka = (int *) malloc(nka * sizeof(int));
if (!ka) {
printf ("<ERROR> : Out of heap space (malloc) !\n");
printf ("<ERROR> : %d int words required\n", nka);
exit (-1);
}
}
***********************

But under linux suse AMD opteron 64, i get this message from the compiler :

warning: cast to pointer from integer of different size

Any explanation ?

Regards,
Lionel.
--
-=O=------------------------------------------=O=-
Lionel Valéro
Analyste Informatique Département Génie Chimique
École Polytechnique de Montréal
C.P. 6079, succ. centre-ville
Montréal (Québec) H3C 3A7
Tel: (514) 340 - 4711 # 4805 / C552
Fax: (514) 340 - 4159
-=O=------------------------------------------=O=-

Nov 13 '05
54 3513
Eric Sosman wrote:
there never seems to be a shortage of people willing to point out
misteaks


I want mine rare, thanks! :-)

Nov 13 '05 #51
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
[...]
If I find a great open source function library implemented in C,
a I obliged to re-implement in C++ so that "C++ folks"
will "deem it good code"? I don't think so.
I just compile it with my C++ compiler
and link it into my C++ programs.


Why not compile it with your C compiler and use extern "C"?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 13 '05 #52
On Thu, 4 Dec 2003 09:14:11 UTC, NFish <no****@nowhere.net> wrote:
The Real OS/2 Guy wrote:
On Mon, 1 Dec 2003 19:00:18 UTC, Lionel Valero
<li***********@polymtl.ca> wrote:

I forgto the headers :
#include <stdio.h>
#include <sys/types.h>
#include <time.h>


You forgot to include stdlib.h again
Lionel Valero wrote:


ka = (int *) malloc(nka * sizeof(int));

And this cast hides the error that you forgot to include the header in
redhat linux.
Casting the result from a function that returns void* is always an
error.


Well, I wouldn't go that far. Consider replacing the first occurrence
of 'a' with 'A" in a block of 100 bytes, given that it exists.

*(char*)memchr(buffer, 'a', sizeof buffer) = 'A';

seems like a reasonable solution.

You'll get 2 problems here:
1. you forgot to include string.h. results in a faulty conversion of
int to char*
as you supperess the diagnostic the compiler will give you.
2. memchr() may return NULL - results in dereferencing a NULL pointer.

Again: never cast the result of a function that returns pointer to
void because the only you get is a faulty program.

--
Tschau/Bye
Herbert

To buy eComStation 1.1 in germany visit http://www.pc-rosenau.de

Nov 13 '05 #53
Keith Thompson wrote:
E. Robert Tisdale writes:
[...]
If I find a great open source function library implemented in C,
a I obliged to re-implement in C++ so that "C++ folks"
will "deem it good code"? I don't think so.
I just compile it with my C++ compiler
and link it into my C++ programs.


Why not compile it with your C compiler and use extern "C"?


extern "C" only *helps* with linkage.
There is no guarantee, for example, that both the C and C++ compiler
will use the same representation for int.
There is no guarantee that both compilers will pass (or return)
arguments in the same registers or on the stack in the same order.
The only reliable way to link C library functions into C++ programs
is to compile them both with the same C++ compiler.

Nov 13 '05 #54
In article <3F************@jpl.nasa.gov>, E.**************@jpl.nasa.gov
says...
extern "C" only *helps* with linkage.
There is no guarantee, for example, that both the C and C++ compiler
will use the same representation for int.


Which platform(s) have C and C++ compilers where this does not work.
Please give a specific example, with example code to show the failure.

--
Randy Howard _o
2reply remove FOOBAR \<,
______________________()/ ()______________________________________________
SCO Spam-magnet: po********@sco.com
Nov 13 '05 #55

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

Similar topics

0
by: jacob nikom | last post by:
Hi, We ran MySQL (4.0.15-standard, 64-bit, SuSe 8.0) benchmarks on 2 CPU and 4 CPU Opteron machines. Mostly we tested insertion times with many simultaneous connections (hundreds). To our...
0
by: Plymouth Acclaim | last post by:
Hi guys, We have a problem with Dual AMD64 Opteron/MySQL 4.0.18/Mandrake 10 for a very high volume site. We are evaluating the performance on our new server AMD64 and it seems it's slow compared...
1
by: Rajrup Banerjee | last post by:
Hi, Does anybody know what are the changes to be done to compile C++ code which uses stl from SGI STL library, using g++ 3.2.3, on Linux running on AMD Opteron 64 bit? Regards, Rajrup.
1
by: louis_pastorik | last post by:
Does anyone have any information about 64 bit python support for Xeon and Opteron architectures on Windows platforms? If anyone has built the python runtime on either of these platforms before I...
1
by: Ericson Smith | last post by:
Hi, We're thinking of moving to a 64 bit platform for our database. Does anyone have any stories of migration from 32 bit to 64 bits? * How did it impact performance? * Were there any gochas?...
0
by: J.Haan | last post by:
Hi all, at the company where I work, we're planning on installing DB2 on an AMD Opteron with 32GB of memory. Let's say we're running DB2 8.1 FP 7 in 64bit mode on SuSE Linux Enterprise Server...
3
by: ashokrathi | last post by:
I am trying to compile SQL procedures on Linux running on AMD/Opteron 64-bit machine. I have 'gcc', 'cc' and 'g++' compilers on my machine. I have set DB2_SQLROUTINE_COMPILE_COMMAND with various...
1
by: Rocael Hernandez | last post by:
Hello all, I was wondering what's best for PG, since we have to decide what will be the new server for our DB, that will serve one or more websites. Our actual configuration is a dual xeon...
4
by: LLessieux | last post by:
Hi, I have been seeing a strange behaviour when doing some tests on a Dual - Dual Core Opteron system using Windows XP (32bits with SP2). In out application we have a wrapper around the thread...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.