473,326 Members | 2,104 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,326 software developers and data experts.

CentOS and redhat


I have a code. I can compile well in redhat. but when I swich to
CentOS
I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'

while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;
va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}

What's the problem?

Jun 22 '07 #1
10 1934
qi*****@gmail.com writes:
I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'
"log" is a function in the standard C library. It computes and
returns the natural logarithm of its floating-point argument.
while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;
Only in C99 may declarations follow statements within a block.
va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}
Attempting to define your own externally visible function named
"log" invokes undefined behavior. I'd suggest renaming your
function.
--
Ben Pfaff
http://benpfaff.org
Jun 22 '07 #2
qi*****@gmail.com wrote:
I have a code. I can compile well in redhat. but when I swich to
CentOS
I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'

while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;
va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}
Probably off-topic given the subject, but it may be that log() is not in
scope, or you are passing it something other than a FILE. Since you
show no relevant code, it's hard to tell.

Can you reduce the problem to the smallest reproduceable (i.e.,
compilable) case?
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 22 '07 #3
In article <11*********************@c77g2000hse.googlegroups. com>,
<qi*****@gmail.comwrote:
>MAPlib.c:16: error: incompatible type for argument 1 of `log'
There's a standard C function called log, for logarithms.
Unfortunately that means you have to call your function something
else.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 22 '07 #4
Richard Tobin wrote:
In article <11*********************@c77g2000hse.googlegroups. com>,
<qi*****@gmail.comwrote:
>MAPlib.c:16: error: incompatible type for argument 1 of `log'

There's a standard C function called log, for logarithms.
Unfortunately that means you have to call your function something
else.
D'oh! Of course.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 22 '07 #5
qi*****@gmail.com wrote:
>
I have a code. I can compile well in redhat. but when I swich to
CentOS I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'

while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;
va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}

What's the problem?
Move the declaration of va_list up one line.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 22 '07 #6
CBFalconer <cb********@yahoo.comwrites:
qi*****@gmail.com wrote:
>>
I have a code. I can compile well in redhat. but when I swich to
CentOS I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'

while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;
va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}

What's the problem?

Move the declaration of va_list up one line.
And why would you expect that to solve "error: incompatible type for
argument 1 of `log'"?

Yes, he should move the declaration of argp up a line if he doesn't
want to depend on either a C99 compiler or a C90 compiler with
extensions, but the real problem seems to be a name collision with the
"log" function declared in <math.h>.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 22 '07 #7
On Fri, 22 Jun 2007 16:30:40 -0000, qi*****@gmail.com wrote:
>
I have a code. I can compile well in redhat. but when I swich to
CentOS
I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'

while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;
va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}

What's the problem?
The error message probably relates to the statement that calls log.
The code you have shown only has parameters, not arguments. We also
need to see the prototype, if any, for log before the function is
defined (in case the compiler diagnostic is using less than precise
terminology).
Remove del for email
Jun 23 '07 #8
On Fri, 22 Jun 2007 09:57:07 -0700, Ben Pfaff <bl*@cs.stanford.edu>
wrote:
>qi*****@gmail.com writes:
>I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'

"log" is a function in the standard C library. It computes and
returns the natural logarithm of its floating-point argument.
>while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;

Only in C99 may declarations follow statements within a block.
> va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}

Attempting to define your own externally visible function named
"log" invokes undefined behavior. I'd suggest renaming your
function.
And to clever monkey, Richard Tobin, and Keith Thompson: There is no
indication that his program contained a #include<math.hdirective.
Without it, there would be no prototype in scope for the standard log
function and the compiler should not be able to match the calling
statement or this function definition to that standard function. A
linker message regarding multiply defined functions with the same name
or a run time error (including any type of undefined behavior) because
the wrong function was called should be the worst that this situation
could produce. A compile time error about argument mismatches just
doesn't seem to flow from this situation.
Remove del for email
Jun 23 '07 #9
Barry Schwarz <sc******@doezl.netwrites:
On Fri, 22 Jun 2007 09:57:07 -0700, Ben Pfaff <bl*@cs.stanford.edu>
wrote:
>>qi*****@gmail.com writes:
>>I ran into problems.
MAPlib.c:16: error: incompatible type for argument 1 of `log'

"log" is a function in the standard C library. It computes and
returns the natural logarithm of its floating-point argument.
>>while my log is defined as
void log(FILE *fp,const char *fmt, ...)
{
if(!debugFlag) return;
va_list argp;

Only in C99 may declarations follow statements within a block.
>> va_start(argp, fmt);
vfprintf(fp, fmt, argp);
va_end(argp);
}

Attempting to define your own externally visible function named
"log" invokes undefined behavior. I'd suggest renaming your
function.

And to clever monkey, Richard Tobin, and Keith Thompson: There is no
indication that his program contained a #include<math.hdirective.
Without it, there would be no prototype in scope for the standard log
function and the compiler should not be able to match the calling
statement or this function definition to that standard function. A
linker message regarding multiply defined functions with the same name
or a run time error (including any type of undefined behavior) because
the wrong function was called should be the worst that this situation
could produce. A compile time error about argument mismatches just
doesn't seem to flow from this situation.
Since log is a predefined function, the compiler may know about it.
I've seen compilers (or at least one) use such knowledge to optimize
certain calls, or to diagnose invalid format strings for printf.
Since the code failed to compile, there was no opportunity for a link
error to appear.

Since the OP didn't show us a complete program, it's entirely possible
that <math.his included, either directly or indirectly. It's also
not clear that the declaration for the OP's own log function was
visible at the point of the call.

And the function's name needs to be changed anyway.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 23 '07 #10
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote:
>Since the OP didn't show us a complete program, it's entirely possible
that <math.his included, either directly or indirectly.
Since the OP said that the behaviour changed when switching between
operating systems, my guess would be that one of them indirectly
includes <math.hand the other doesn't.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 23 '07 #11

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

Similar topics

2
by: rbt | last post by:
Not really a Python question, but I thought some on this list may be able to answer.... so here goes: I have several machines on which I must install CentOS. There are many updates to CentOS and...
4
by: D. Dante Lorenso | last post by:
This isn't entirely PG related, but... Does anyone know what the natural upgrade path from RedHat 9 is? I'm wondering if anyone on the PostgreSQL team is working with redhat to package and...
1
by: rich | last post by:
I want to upgrade php 4.3.9 and postgresql 7.4.13 on Centos 4.3 to php 5.1.4 and postgresql 8.1.4 using rpms. Has anyone done this?
0
by: Chen Yang | last post by:
Hi all, I have been working on this problem for two days, any suggestion would be very appreciated. I am installing Tomcat5 on CentOS 4.2 with the following instructions:...
8
by: MacRules | last post by:
In office, I can have RedHat AS 4.0. And I like to configure a DB2 for home lab system. Which one is better OpenSuse 10.3 or CentOS?
3
by: Alexandre Gillet | last post by:
Hi, I am trying to build python-2.4.5 on Centos 5.1, which is a virtual machine running with xen. I am not able to build python. The compilation crash with the following: gcc -pthread -c ...
0
by: Alexandre Gillet | last post by:
Thanks for your answers. I did solve my problem. I upgraded my glibc libraries and it seems to solve the problem. I was able to build python-2.4.5 using gcc 4.1.2 (glibc-2.5-18.el5_1.1) Alex ...
1
by: F. | last post by:
Hello, I have problems making python on CentOS 5. Seems that can not find something. I can not find the problem. Where is the problem?
3
by: Brendan | last post by:
The current CentOs Linux distro includes python 2.4.3. I need to install a more recent version but I am worried about breaking CentOs python dependencies. Is it safe to install python 2.6 using pup?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.