473,387 Members | 1,603 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,387 software developers and data experts.

[Q]function name and variable name conflict.

When compile using g++, following error messages appears.

/usr/include/sys/sysinfo.h:101: `struct sysinfo_t sysinfo' redeclared
as differe
nt kind of symbol
/usr/include/sys/systeminfo.h:77: previous declaration of `int
sysinfo(int, char
*, long int)'
....
szh.cpp:899: no match for call to `(sysinfo_t) (int, char[256], long
int)'
make: *** [szh.o] Error 1

It seems that g++ could not distinguish sysinfo(2) system call from
sysinfo structure variable.
How can I solve this provblem...? Hope advice.

Chun-Mok Chung.
Jul 19 '05 #1
2 4726
On 1 Sep 2003 22:37:24 -0700, ch*****@hanmail.net (chunmok) wrote in
comp.lang.c++:
When compile using g++, following error messages appears.

/usr/include/sys/sysinfo.h:101: `struct sysinfo_t sysinfo' redeclared
as differe
nt kind of symbol
/usr/include/sys/systeminfo.h:77: previous declaration of `int
sysinfo(int, char
*, long int)'
...
szh.cpp:899: no match for call to `(sysinfo_t) (int, char[256], long
int)'
make: *** [szh.o] Error 1

It seems that g++ could not distinguish sysinfo(2) system call from
sysinfo structure variable.
How can I solve this provblem...? Hope advice.

Chun-Mok Chung.


Rename one or the other. You can't use the same name as both a
function and an object in the same namespace.

Alternatively ask in a gcc or a Linux (or your particular *NIX flavor)
group. Note that neither of these headers is part of standard C++,
they are platform specific extensions.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 19 '05 #2
ch*****@hanmail.net (chunmok) writes:
When compile using g++, following error messages appears.

/usr/include/sys/sysinfo.h:101: `struct sysinfo_t sysinfo' redeclared
as differe
nt kind of symbol
/usr/include/sys/systeminfo.h:77: previous declaration of `int
sysinfo(int, char
*, long int)'
...
szh.cpp:899: no match for call to `(sysinfo_t) (int, char[256], long
int)'
make: *** [szh.o] Error 1

It seems that g++ could not distinguish sysinfo(2) system call from
sysinfo structure variable.
How can I solve this provblem...? Hope advice.


Wrap one of them.

--- sysinfo_wrapper.h ---

#ifdef SYSINFO_WRAPPER_H
#define SYSINFO_WRAPPER_H
int sysinfo_wrapper(int, char* long int);
#endif
//SYSINFO_WRAPPER_H

___ sysinfo_wrapper.cc --

#include "sysinfo_wrapper.h"
#include <sys/sysinfo.h>

int sysinfo_wrapper(int i, char* c, long int l)
{
sysinfo(i,c,l);
}

Then, never #include sys/sysinfo.h anwhere - always include
sysinfo_wrapper.h instead, and call sysinfo_wrapper.
Jul 19 '05 #3

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

Similar topics

15
by: Bob | last post by:
I've tried everything; and I can't seem to get past this VERY (seemingly) simply problem. I want to work with an array variable within a function(s). I can't get it to work; if I: 1) global...
26
by: Roland Hall | last post by:
I'm tired of getting beat up on this issue so I thought I'd ask what you some of you think. I know the basic difference between a subroutine and a function is a subroutine performs a task and a...
1
by: S.Tobias | last post by:
typedef int myint; struct s { myint myint; /* 1 */ } s; int main() { myint myint; /* 2 */
13
by: Roy Hills | last post by:
I've seen two different function prototype formats used for ANSI C, and I'm unsure as to which is the correct or preferred one. 1st Format (this is what I use) type function(type, type, type);...
20
by: ramubdvt | last post by:
hi, i have written this strcat but sometime it is giving problem, while handeling some strings containing binary and if string containing zero , funtion which takes string 1 and its length...
2
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance. I'm having trouble with something that I'm trying for the first time. Using Access 2000 - I want to run a function either on the click of a...
20
by: Christian Christmann | last post by:
Hi, in a benchmark I've found an uncommon use of a function. This is the simplified form: 1 int foo( int f ) 2 { 3 return f; 4 } 5
7
by: lovecreatesbea... | last post by:
Shoud we declare non-pointer function parameters with const keywords? int main(void){ int f(const int i); int i; f(i); return 0; }
9
by: Meendar | last post by:
Hi, Below is my code snippet having only one form, <form> <input type ="radio" name="action" value="xyz" checked>xyz <input type ="radio" name="action" value="zyx">zyx <input type ="radio"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.