Skip to content

Made changes for C++, general usability#5

Open
samgubernick wants to merge 1 commit intonicolausYes:masterfrom
samgubernick:master
Open

Made changes for C++, general usability#5
samgubernick wants to merge 1 commit intonicolausYes:masterfrom
samgubernick:master

Conversation

@samgubernick
Copy link

-Moved dynamic easing functions to dedicated file
-Added regular functions and namespaces
-Removed dependency from easing.cpp (now in easing_dynamic.cpp)
-Added decimals to whole numbers (1, 2, ... are now 1.0, 2.0, ...)
-Changed types to auto
-Removed leading and trailing spaces
-Changed header file format to .hpp
-Changed lowercase class names to capitalized first letter of words
-Added include guards
-Changed easing enum to enum class

-Added regular functions and namespaces
-Removed <map> dependency from easing.cpp
-Added decimals to whole numbers (1, 2, ... are now 1.0, 2.0, ...)
-Changed types to auto
-Removed leading and trailing spaces

#ifndef EASING_EASING_HPP_INCLUDED
#define EASING_EASING_HPP_INCLUDED
#pragma once

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to have both the ifndef guard and the pragma once?

@TheRaffy
Copy link

Source: https://stackoverflow.com/questions/1143936/pragma-once-vs-include-guards
The reasons are :

#pragma once is not standard, so it is possible that some compiler don't provide the functionality. That said, all major compiler supports it. If a compiler don't know it, at least it will be ignored.
As there is no standard behavior for #pragma once, you shouldn't assume that the behavior will be the same on all compiler. The guards will ensure at least that the basic assumption is the same for all compilers that at least implement the needed preprocessor instructions for guards.
On most compilers, #pragma once will speed up compilation (of one cpp) because the compiler will not reopen the file containing this instruction. So having it in a file might help, or not, depending on the compiler. I heard g++ can do the same optimization when guards are detected but it have to be confirmed.

Using the two together you get the best of each compiler for this.

(I didnt know as well, but now I do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants