Skip to content

Commit e9468e9

Browse files
authored
Merge pull request #1 from bertof/master
Added sbf namespace to end.h and moved implementation to end.cpp - Moved the function is_big_endian to the sbf namespace, so that it doesn't conflict with the global scope. - Separated the header from the implementation, so that it follows C++ standard (and g++ doesn't mistake it for a double definition of the same function).
2 parents 6decf26 + 522b274 commit e9468e9

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

end.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "end.h"
2+
3+
namespace sbf {
4+
5+
int is_big_endian(void){
6+
union {
7+
uint32_t i;
8+
char c[4];
9+
} bi = { 0x01020304 };
10+
11+
return bi.c[0] == 1;
12+
}
13+
14+
} //namespace sbf

end.h

+5-9
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2626

2727
#include <stdint.h>
2828

29-
int is_big_endian(void)
30-
{
31-
union {
32-
uint32_t i;
33-
char c[4];
34-
} bi = { 0x01020304 };
35-
36-
return bi.c[0] == 1;
37-
}
29+
namespace sbf {
30+
31+
int is_big_endian(void);
32+
33+
} //namespace sbf
3834

3935
#endif /* END_H */

0 commit comments

Comments
 (0)