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

Help on warning: non-static const member in class without a constructor

Following warnings are found in my application:

..../adm_std_mo_descr.h:240: warning: non-static const member `const
struct std_tee_t std_mo::tee' in class without a constructor
..../adm_std_mo_descr.h:244: warning: non-static const member `const
char *const std_mo::name' in class without a constructor

The header file looks as the following:

typedef struct std_tee {
const unsigned int size;
} std_tee_t;
typedef struct std_mo {
const std_tee_t tee;
const char* const name;
} std_mo_t;

I am wondering what the problem is. I tried to write a small test
program, but it compiles without such warning.

I am using gcc2.7.2 on Tornado/VxWorks.

Thanks a lot for your help.
Zhixin

Nov 14 '05 #1
6 4044
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

zh********@hotmail.com wrote:
Following warnings are found in my application:

.../adm_std_mo_descr.h:240: warning: non-static const member `const
struct std_tee_t std_mo::tee' in class without a constructor

[snip]

You don't have to look any further than this first error message.

Since the C language neither has the classes nor the constructors that
your compiler is complaining about, you are not compiling your code with
a C compiler.

Use a C compiler on your C code, and see if that fixes your problem
- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFCsF4EagVFX4UWr64RAomyAKDGH2QM7fbwOZqLYcZscE SL/a8XrgCgh8k/
roPJQZlxhN/lefoQjDoSK8g=
=LoVU
-----END PGP SIGNATURE-----
Nov 14 '05 #2
On Wed, 15 Jun 2005 07:49:51 -0700, zhixin_han wrote:
Following warnings are found in my application:

.../adm_std_mo_descr.h:240: warning: non-static const member `const
struct std_tee_t std_mo::tee' in class without a constructor
.../adm_std_mo_descr.h:244: warning: non-static const member `const
char *const std_mo::name' in class without a constructor
C doersn't have classes or constructirs, you appear to be trying to
compile your code with a C++ compiler. Solution: compile C code with a C
compiler.

....
I am using gcc2.7.2 on Tornado/VxWorks.


Compilers are often sensitive to the extension of the source filename.
Make sure it is .c rather than, sap, .cpp or .C

Lawrence
Nov 14 '05 #3


zh********@hotmail.com wrote:

Following warnings are found in my application:

.../adm_std_mo_descr.h:240: warning: non-static const member `const
struct std_tee_t std_mo::tee' in class without a constructor
.../adm_std_mo_descr.h:244: warning: non-static const member `const
char *const std_mo::name' in class without a constructor

The header file looks as the following:

typedef struct std_tee {
const unsigned int size;
} std_tee_t;

typedef struct std_mo {
const std_tee_t tee;
const char* const name;
} std_mo_t;

I am wondering what the problem is. I tried to write a small test
program, but it compiles without such warning.

I am using gcc2.7.2 on Tornado/VxWorks.

Thanks a lot for your help.

Zhixin
No such thing as a constructor, or a class, in C. Perhaps you want C++
or java.

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225
#! rnews 1963
Xref: xyzzy comp.lang.c:560602
Newsgroups: comp.lang.c
Path: xyzzy!nntp
From: "Fred L. Kleinschmidt" <fred.l.kleinschmidt@nospam_boeing.com>
Subject: Re: Methods to handle filename extensions?
X-Nntp-Posting-Host: xpc-ps-06.nw.nos.boeing.com
Content-Type: text/plain; charset=us-ascii
Message-ID: <42B06322.77DD6648@nospam_boeing.com>
Sender: nn**@news.boeing.com (Boeing NNTP News Access)
Content-Transfer-Encoding: 7bit
Organization: Boeing
X-Accept-Language: en
References: <11**********************@f14g2000cwb.googlegroups .com>
Mime-Version: 1.0
Date: Wed, 15 Jun 2005 17:19:30 GMT
X-Mailer: Mozilla 4.79 [en]C-CCK-MCD Boeing Kit (Windows NT 5.0; U)

gm********@yahoo.com wrote:
I need assistance coming up with a clean way to handle filename
extensions with my application.

While I can come up with several ways of doing so on my own, I felt
perhaps it would be worth asking here to see what more effective or
accepted methods for doing would be presented.

The issue is this. My application accepts files names, intended for
a cross platform unix and windows environment, from the command line.
So the application may get a file name '/home/joe/myExample.ct',
'C:\Work\myExample.ct' or more generically 'myExample.ct' My
application is to convert the data in the .ct file, into something new,
then enter the data into a file in the local directory the application
was executed named 'myExample.out'.

Is their a simplified way to handle this problem?

Tony


problem? What problem?

FILE *fin, *fout;
char *inputfile = argv[1]; /* for example */
char *outputfile = "myExample.out";

fin = fopen( inputfile, "r" );
/* don't forget to test for success */
fout = fopen( outputfile, "w" );
/* ditto on success check */
/* now read from fin, process, and write to fout */

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225
Nov 14 '05 #4
zh********@hotmail.com wrote:

Following warnings are found in my application:

.../adm_std_mo_descr.h:240: warning: non-static const member `const
struct std_tee_t std_mo::tee' in class without a constructor
.../adm_std_mo_descr.h:244: warning: non-static const member `const
char *const std_mo::name' in class without a constructor


comp.lang.c++ is down the hall on the right. The C language does
not have those things.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #5
Thanks everybody. I finally found that option "-x c++" is among the
options used in gcc. That explains it.

Evan
CBFalconer wrote:
zh********@hotmail.com wrote:

Following warnings are found in my application:

.../adm_std_mo_descr.h:240: warning: non-static const member `const
struct std_tee_t std_mo::tee' in class without a constructor
.../adm_std_mo_descr.h:244: warning: non-static const member `const
char *const std_mo::name' in class without a constructor


comp.lang.c++ is down the hall on the right. The C language does
not have those things.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


Nov 14 '05 #6

Le 16/06/2005 17:43, dans
11**********************@o13g2000cwo.googlegroups. com,
«*zh********@hotmail.com*» <zh********@hotmail.com> a écrit*:
Thanks everybody. I finally found that option "-x c++" is among the
options used in gcc. That explains it.


A new kind of bug: the compiler option bug :-)

Nov 14 '05 #7

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

Similar topics

4
by: Chefry | last post by:
I'm trying to set up an off the shelf script and keep getting an error. My host set up the mysql on my site and I changed the variables I had to in the settings.php file but I keep getting the...
12
by: Daniel Sjöblom | last post by:
When I compile this (with GCC and optimizations on): void foo(void) { int a; float f = *((float *) &a); } I get the warning : "dereferencing type-punned pointer will break strict-aliasing...
43
by: Anitha | last post by:
Hi I observed something while coding the other day: if I declare a character array as char s, and try to use it as any other character array..it works perfectly fine most of the times. It...
40
by: Dave Hansen | last post by:
Please note crosspost. Often when writing code requiring function pointers, it is necessary to write functions that ignore their formal parameters. For example, a state machine function might...
5
by: Hatim Ali | last post by:
Hello folks, I've integrated my ASP.NET website with a portal on web. My website opens in a frame provided by the web portal. The portal uses https protocol. Now when i open my website IE...
21
by: sulays | last post by:
I need to insert and sort in a link list
10
by: Rich Sienkiewicz | last post by:
The C# compiler gives warnings about unused variables. I thin it needs a warning about an unassigned reference. For instance, this compiles without any warnings/errors, but of course blows up when...
10
by: shadab | last post by:
I am having big problem retrieving data assgined to dynamic 2-d array . i am calculating and saving data in to dynamic 2-d array. but when i retrieve them, it doesnt give correct values. you...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
20
by: @$|-|. DUBEY | last post by:
i have a interger val = 99999; and i want to add the content of val i.e., 9+9+9+9+9 = 45; how to do that.... need urgent help
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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...

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.