Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2008 by Ivor Horton; ISBN: 9780470225905
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2008, 11:30 AM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default #pragma

Please , help !!!
I don't understand clearly what the function of #pragma is .
Please give me some documents , some information or explanation .
Thanks.
 
Old December 18th, 2008, 03:15 AM
Authorized User
 
Join Date: Nov 2008
Posts: 15
Thanks: 1
Thanked 1 Time in 1 Post
Default

Pragma is a compiler directive that's machine or operating system specific.

You can read about it here: http://msdn.microsoft.com/en-us/library/d9x1s805.aspx

Like any compiler directive, it's processed before your program is actually compiled. For instance, the #pragma once directive asks the compiler to include a header file only once, in case multiple included files contain references to the same header. This happens prior to compilation.

Pragma directives are generally specific to a machine or operating system, so I suppose they're not recommended for cross-platform development.

Hope this helps...
 
Old December 18th, 2008, 05:33 AM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Beside using this directive (#pragma) , in C++ is there any other way which has the same as function of #pragma
 
Old December 18th, 2008, 05:35 AM
Registered User
 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default New thread

hi i am new to wrox forums .can anyone tell me the steps to post new thread.
Thanks to you
 
Old December 18th, 2008, 08:06 AM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default

- Sign in
- Select the book forum .
- Step 1 : click on Newthread .
- Step 2 : type your title and message .
- Step 3 : click on submit thread .
That's all .
 
Old December 18th, 2008, 03:11 PM
Authorized User
 
Join Date: Nov 2008
Posts: 15
Thanks: 1
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by phuc_tran View Post
Beside using this directive (#pragma) , in C++ is there any other way which has the same as function of #pragma
It depends. There isn't just one #pragma command, there are several commands with the #pragma directive (follow the link I included previously). Many, if not most, are specific to the compiler, OS, or machine that they're designed for.

For the example I cited above, #pragma once, there is an ANSI equivalent listed on page 455 of the book.
Code:
#ifndef BOX_H
#define BOX_H
// Header file code here
//
#endif
For the others, I imagine there are some cross-platform compatible equivalents, but due to the nature of #pragma, it has no universal equivalent.
 
Old December 18th, 2008, 08:18 PM
Authorized User
 
Join Date: Dec 2008
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Dear Sally !
As you said , we can define a new header file (BOX_H) which has the same as function as #pragma , and #pragma is not universal . Is that right ?
I wanna ask is there any header file or key word or .... in C++ which can do the same work like #pragma
Thank Sally for helping !!!









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.