M
M
Max Suprunenko2015-10-13 18:40:33
C++ / C#
Max Suprunenko, 2015-10-13 18:40:33

Which directive is better to use for a class (#pragma once) or (#ifndef)?

Which directive is better to use for a class (#pragma once) or (#ifndef)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Taratin, 2015-10-13
@msuprunenko

I am for #pragma once
#ifndef a crutch invented instead of implementing a normal modular system, at least like the same Pascal, if we talk about bearded times.

R
robotzet, 2015-10-13
@robotzet

Stackoverflow
tl;dr: Use
what you like best.

E
Eddy_Em, 2015-10-14
@Eddy_Em

And I use both options in header files. The outer one is pragma once, the inner one is ifndef. I already have auto-generation of these "brackets" posted on ifndef in geany. The fact is that not all compilers understand pragma once yet, for example, there were such problems with sdcc (I don’t know how it is now - I didn’t check it specifically).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question