473,698 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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 4746
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.l earn.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_wrappe r.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
2340
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 $arr=array(); (syntax err) 2) global $arr; in "main", the var isn't global 3) global $arr; in function, the array is cleared each time
26
10801
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 function performs a task and returns a value. The Call keyword is required when using parens with subs with more than 1 parameters. Parens around values passed are ByVal vs ByRef and is a waste of processing if passed ByRef for no reason. I...
1
1423
by: S.Tobias | last post by:
typedef int myint; struct s { myint myint; /* 1 */ } s; int main() { myint myint; /* 2 */
13
4342
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); e.g. "int multiply(int, int);" 2nd Format (I've seen this used in other people's code)
20
3803
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 string2 and its length as arguments please tell the correction , here iam using
2
4849
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 button or on leaving a text box. For the immediate task, either will work as well as the other. I think. I'm just at the beginning of this, and the form has two text boxes - Text0 and Text1. The user input to Text0 is a dollar amount, in...
20
2366
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
2228
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
1741
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" name="action" value="yxz">yxz </form>
0
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.