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

Z

zhixin_han

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
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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)

iD8DBQFCsF4EagVFX4UWr64RAomyAKDGH2QM7fbwOZqLYcZscESL/a8XrgCgh8k/
roPJQZlxhN/lefoQjDoSK8g=
=LoVU
-----END PGP SIGNATURE-----
 
F

Fred L. Kleinschmidt

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: (e-mail address removed) (Boeing NNTP News Access)
Content-Transfer-Encoding: 7bit
Organization: Boeing
X-Accept-Language: en
References: <[email protected]>
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)



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 */
 
C

CBFalconer

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.
 
L

Lawrence Kirby

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
 
Z

zhixin_han

Thanks everybody. I finally found that option "-x c++" is among the
options used in gcc. That explains it.

Evan
 
J

Jean-Claude Arbaut

Le 16/06/2005 17:43, dans
(e-mail address removed),
« [email protected] » said:
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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top