Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


#pragma once?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Tue Sep 25, 2007 8:45 pm    Post subject: #pragma once? Reply with quote

In C++ I sometimes see code and they are using #pragma once, I mean what does that even do?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Sep 25, 2007 8:55 pm    Post subject: Reply with quote

Insures the header file will only be included once (so you don't run into problems like type and function redefinitions)
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Wed Sep 26, 2007 2:52 am    Post subject: Reply with quote

How do you use this exactly?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Sep 26, 2007 3:53 am    Post subject: Reply with quote

Just add #pragma once to the top of the file.

It's a newer method of doing:

Code:
#ifndef _H_INCLUDE_NAME_
#define _H_INCLUDE_NAME_

// Your Code Here

#endif // _H_INCLUDE_NAME_
Back to top
View user's profile Send private message Visit poster's website
TerryDonahugh
Master Cheater
Reputation: 0

Joined: 12 Sep 2007
Posts: 412
Location: .nl

PostPosted: Wed Sep 26, 2007 2:47 pm    Post subject: Reply with quote

Wiccaan wrote:
Just add #pragma once to the top of the file.

It's a newer method of doing:

Code:
#ifndef _H_INCLUDE_NAME_
#define _H_INCLUDE_NAME_

// Your Code Here

#endif // _H_INCLUDE_NAME_


Not really a newer way to do it, it is a Microsoft extension to the language. #pragma once is not standardized and has even been obsoleted in GCC.

Note that #pragma is used for vendor specific extensions to C/C++.

_________________
Hello? Mule Farm


Last edited by TerryDonahugh on Thu Sep 27, 2007 2:52 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Sep 26, 2007 6:16 pm    Post subject: Reply with quote

I mainly code in VS which is why I mentioned it being 'newer'. As Microsoft notes too, #pragma once can greatly increase compile times, but as you already said, portability comes into play then as some compilers, like GCC, have issues with it which label it obsolete.

According to the Wiki:
LCC (2004) labeled it as having issues.
GCC (1998) labeled it as having issues, then 2005 as obsolete.

For me since I code mainly in VS2005, I just use #pragma once. Most of my old work has been closed source so I never had to worry about others having to compile my stuff so I never bothered with the other method except for older projects when I used VS6.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites