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

g++ wrarning hides constructor

Hi,

I have code like this

file1.h
=======
typedef struct myStructName{
....
...
...
}MyStructName;

file2.h
=======
extern int myStructName (MyStructName *myName);
file3.c
======
#include "file1.h"
#include "file2.h"
.......
.......
.......
While compling with g++ I am getting warning like,
In file included from file3.c:line #:
file2.h :279: warning: `int myStructName (MyStructName *)' hides
constructor for `struct myStructName'

Is there any compile time option to hise this warning? or any other
solution to hide this warning

Thankns
Husain

Sep 12 '05 #1
2 3677
> Is there any compile time option to hise this warning? or any other
solution to hide this warning


Use unique names ?

--
Karl Heinz Buchegger
kb******@gascad.at
Sep 12 '05 #2
hu******@gmail.com wrote:
Hi,

I have code like this

typedef struct myStructName{
}MyStructName;

extern int myStructName (MyStructName *myName);

While compling with g++ I am getting warning like,
file2.h :279: warning: `int myStructName (MyStructName *)' hides
constructor for `struct myStructName'
In case you didn't understand the error: "myStructName" is
a type name. Then you declare a function called "myStructName".
So you have a type and a function with the same name.
The warning is telling you that you now will not be able to
construct an object like:

myStructName s;

because the function name hides the type name.
(Of course, you can construct it using its alias "MyStructName",
or by specifying "struct myStructName").
Is there any compile time option to hise this warning? or any
other solution to hide this warning


IMHO the best thing to do is to stop using the same name
for a function and a type !

You should declare your struct as:

struct MyStructName
{
};

The typedef is just a waste of space (why declare 2 type names
when you only need one?)

Sep 12 '05 #3

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

Similar topics

3
by: Aire | last post by:
Will defining a copy constructor also make the default constructor not available anymore, until a default constructor is explicitly provided? Thanks!
3
by: Tom | last post by:
Hello, I've searched groups and the std unsuccessfully for an explanation of the following - I'd appreciate any comments you may have. Given the following diamond multiple inheritance pattern,...
26
by: Paul | last post by:
public class A { public A () { // here I would like to call the second version of _ctor, how to accomplish this ? } public A (int a, int b, int c) {
8
by: Sam Kuehn | last post by:
How do I accomplish the fallowing (is it even possible). Say I write a UserControl "MyControl.ascx". Now I use LoadControl("MyControl.ascx"). But I really want MyControl to require parameters in...
11
by: RickHodder | last post by:
I'm having a problem, and here is a simplified example of code that demonstrates it: public class BizObj { public string TableName=""; private DataSet oData; public BizObj()
11
by: fourfires.d | last post by:
Dear All, I am new to c++ and when write below code that try to call copy constructor in "=" operator overloading, it can not compile. Can anyone point out for me the reason? thanks !! ...
6
by: Taran | last post by:
Hi All, I tried something with the C++ I know and some things just seem strange. consider: #include <iostream> using namespace std;
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
10
by: Jason Doucette | last post by:
Situation: I have a simple struct that, say, holds a color (R, G, and B). I created my own constructors to ease its creation. As a result, I lose the default constructor. I dislike this, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.