compilation warning # pragma once

S

Subrat

Hello,
I have used #pragma once in a header file.
During compilation I get a warning : #pragma once is obsolete.
How do I switch off this warning, without making any change to my make file?

Thanks in Advance,
Subrat
 
R

red floyd

Subrat said:
Hello,
I have used #pragma once in a header file.
During compilation I get a warning : #pragma once is obsolete.
How do I switch off this warning, without making any change to my make file?

Thanks in Advance,
Subrat
Wrong group. #pragma's are implementation specific. How to disable
warnings is implementation specific. Try a group with microsoft or
vc in its name.

See FAQ 5.9 http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
 
J

Jim Langston

Subrat said:
Hello,
I have used #pragma once in a header file.
During compilation I get a warning : #pragma once is obsolete.
How do I switch off this warning, without making any change to my make
file?

Easiest way, go into the header file, remvoe #pragma once and replace it
with the proper include guards.
#ifndef MYFILE_H
#define MYFILE_H

// header here

#endif

MYFILE_HEADER
is also sometimes used.
 
J

James Kanze

Easiest way, go into the header file, remvoe #pragma once and replace it
with the proper include guards.
#ifndef MYFILE_H
#define MYFILE_H
// header here

MYFILE_HEADER
is also sometimes used.

Many different conventions are sometimes used (inluding some
which are formally illegal, e.g. _MYFILE_H). The important
point is to avoid the risk of collisions. For this reason, most
libraries will try to munge the name of the library into the
guard (e.g. BOOST_..._INCLUDED); anything really professional
will probably include some sort of random sequence as well. (I
get toto_hh_20080702Jbqi2me5hF1pQrgColbxnIMk for a file toto.hh,
although I'll get something else if I create it again; the last
24 characters are generated from input from /dev/random.
Another possibility might be an MD-5 or SHA-1 digest of the
hostname and the full pathname from the root, or the filename,
programmer name and the current time and date.)
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top