Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML Blueprints - Another SFML book  (Read 53824 times)

0 Members and 2 Guests are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML Blueprints - Another SFML book
« Reply #15 on: September 12, 2015, 11:28:40 am »
- i had to replace logical operators written like this: 'not', 'and'.. to '!', '&&'

Would be great if somebody knew how to handle problem with logical operators.
It has been pointed out to the author before the book was released, but the report was not taken seriously...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

select_this

  • Full Member
  • ***
  • Posts: 130
  • Current mood: just ate a pinecone
    • View Profile
    • darrenferrie.com
Re: SFML Blueprints - Another SFML book
« Reply #16 on: September 12, 2015, 01:48:24 pm »
It's possible to get VS to understand alternative operator tokens, according to http://stackoverflow.com/questions/24414124/why-does-vs-not-define-the-alternative-tokens-for-logical-operators. Even so, as far as I'm aware their usage isn't all that common (except where I work right now, where the coding standard mandates their use...)
Follow me on Twitter, why don'tcha? @select_this

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Blueprints - Another SFML book
« Reply #17 on: September 12, 2015, 03:21:38 pm »
99.9% of C++ projects avoid those keywords, it's well-known that they're not portable. Unfortunately it seems like not even Visual Studio, one of the most widely used IDEs, has been used for testing...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: SFML Blueprints - Another SFML book
« Reply #18 on: September 12, 2015, 03:25:03 pm »
I have to admit, that I didn't even know these alternative keywords existed and I use C/C++ for quite some time now(~15 years):o

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: SFML Blueprints - Another SFML book
« Reply #19 on: September 12, 2015, 03:31:34 pm »
I have to admit, that I didn't even know these alternative keywords existed and I use C/C++ for quite some time now(~15 years):o
If you want to write really wonky looking code there's also digraphs and trigraphs to play with ;)

Krozark

  • Newbie
  • *
  • Posts: 36
    • View Profile
    • site perso
Re: SFML Blueprints - Another SFML book
« Reply #20 on: September 12, 2015, 04:29:57 pm »
99.9% of C++ projects avoid those keywords, it's well-known that they're not portable. Unfortunately it seems like not even Visual Studio, one of the most widely used IDEs, has been used for testing...

I've point this in the first chapter of the book. Visual studio doesn't sported full C++11 (VS 2013), and some feature not supported where required (don't remember which one).
You can use mingw our clang (as suggested in the same chapter), and all will  be fine (tested on linux/windows).

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: SFML Blueprints - Another SFML book
« Reply #21 on: September 12, 2015, 04:39:26 pm »
Doesn't change the fact that using stuff like 'not' and 'and' is uncommon, weird, not well supported and generally avoided.
It's really not something you'd want to use in a modern C++ book.

Krozark

  • Newbie
  • *
  • Posts: 36
    • View Profile
    • site perso
Re: SFML Blueprints - Another SFML book
« Reply #22 on: September 12, 2015, 04:47:40 pm »
Those operators are specified in the standard. I don't see why I should avoid them. All the good compiler support them.
And if you really want to use visual studio, you can activate them with a flag, but I don't remember which on.
EDIT : the flag is /Za according to https://msdn.microsoft.com/en-us/library/vstudio/2e6a4at9%28v=vs.110%29.aspx
« Last Edit: September 13, 2015, 12:51:54 am by Krozark »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: SFML Blueprints - Another SFML book
« Reply #23 on: September 12, 2015, 04:54:23 pm »
You should avoid them since they are very rarely used and even many experienced C++ developers don't know they exist.
They are a legacy from a time where many systems couldn't type characters like "!", "{" and "|". These days they should just be avoided. C++17 even removes (not just deprecate) a lot of that old cruft.
It's like "the 80's called; they want their trigraphs back" ;)
« Last Edit: September 12, 2015, 05:10:24 pm by Jesper Juhl »

zombox

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: SFML Blueprints - Another SFML book
« Reply #24 on: September 13, 2015, 12:13:18 am »
I've point this in the first chapter of the book. Visual studio doesn't sported full C++11 (VS 2013), and some feature not supported where required (don't remember which one).
You can use mingw our clang (as suggested in the same chapter), and all will  be fine (tested on linux/windows).
I tried mingw, but I'm getting:
Code: [Select]
[ 15%] Built target Box2D
Linking CXX shared library ..\..\..\lib\sfgui.dll
CMakeFiles\sfgui.dir/objects.a(Button.cpp.obj):Button.cpp:(.text+0x1d8): undefin
ed reference to `_imp___ZN2sf6StringaSERKS0_'
CMakeFiles\sfgui.dir/objects.a(Button.cpp.obj):Button.cpp:(.text+0x8a2): undefin
ed reference to `_imp___ZNK2sf6String7getSizeEv'
C:\MinGW\bin/ld.exe: CMakeFiles\sfgui.dir/objects.a(Button.cpp.obj): bad reloc a
ddress 0x12 in section `.text$_ZNSt12__shared_ptrIN3sfg6ButtonELN9__gnu_cxx12_Lo
ck_policyE2EED2Ev[__ZNSt12__shared_ptrIN3sfg6ButtonELN9__gnu_cxx12_Lock_policyE2
EED2Ev]'
collect2.exe: error: ld returned 1 exit status
extlibs\SFGUI\CMakeFiles\sfgui.dir\build.make:1996: recipe for target '../lib/sf
gui.dll' failed
mingw32-make[2]: *** [../lib/sfgui.dll] Error 1
CMakeFiles\Makefile2:124: recipe for target 'extlibs/SFGUI/CMakeFiles/sfgui.dir/
all' failed
mingw32-make[1]: *** [extlibs/SFGUI/CMakeFiles/sfgui.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Krozark

  • Newbie
  • *
  • Posts: 36
    • View Profile
    • site perso
Re: SFML Blueprints - Another SFML book
« Reply #25 on: September 13, 2015, 12:49:08 am »
They are a legacy from a time where many systems couldn't type characters like "!", "{" and "|". These days they should just be avoided. C++17 even removes (not just deprecate) a lot of that old cruft.
It's like "the 80's called; they want their trigraphs back" ;)

You're wrong.
C++17  rewove Trigraph ( ??<, ??( ,...) that's true.
But here we are speaking of the alternative operators (and, or, not, xor, bit_or, ...) of standard ISO C++  created a while ago.

I understand that it can be confusing at first but, we are talking about a book. And the goal of it is to learn some new thing to the reader. Maybe it can be the first one.

Personally I think that it's more readable, and you avoid mistakes like "|" instead of "||".
I don't know any reason to avoid them, now if there is a real one (and don't say "Nobody is using it, so don't") please let me know.

I tried mingw, but I'm getting

I'm not able to reproduce your link error. Can you share your compiler version.
It look like a linker error on sfgui.
Did you take the code here : https://github.com/Krozark/SFML-book ?
« Last Edit: September 13, 2015, 02:41:35 pm by Krozark »

zombox

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: SFML Blueprints - Another SFML book
« Reply #26 on: September 13, 2015, 01:55:13 am »
@Krozark
4.8.1 and the code is from repo. Since you compiled, could you just share binaries?

Krozark

  • Newbie
  • *
  • Posts: 36
    • View Profile
    • site perso
Re: SFML Blueprints - Another SFML book
« Reply #27 on: September 13, 2015, 03:48:39 pm »
Since you compiled, could you just share binaries?

I've add them here : https://github.com/Krozark/SFML-book/tree/master/bin/win64 (build on windows 8 x64)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Blueprints - Another SFML book
« Reply #28 on: September 13, 2015, 03:55:11 pm »
Personally I think that it's more readable, and you avoid mistakes like "|" instead of "||".
Every C++ programmer knows && and ||. 1% of C++ programmers know and and or. So it is not more readable to most developers.

I don't know any reason to avoid them, now if there is a real one (and don't say "Nobody is using it, so don't") please let me know.
If you don't believe that many C++ developers are confused by those keywords, then at least accept that the probably most widely used C++ IDE does not support them by default. It's of course your decision what you want to support and what not, but you unnecessarily limit your audience.
« Last Edit: September 13, 2015, 03:59:23 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Krozark

  • Newbie
  • *
  • Posts: 36
    • View Profile
    • site perso
Re: SFML Blueprints - Another SFML book
« Reply #29 on: September 13, 2015, 04:06:18 pm »
If you don't believe that many C++ developers are confused by those keywords

I've admit this in a previous message :
I understand that it can be confusing at first

then at least accept that the probably most widely used C++ IDE does not support them

I only tried Code::Block and Visual Studio as IDE for C++, so I can only speak for them (I personally, used GVim). The first on support them completely (without any changes), and the second on with the flag /Za.
The reason that Visual studio don't support them by default is to be compatible with C (according to my research on the subject). But we make C++ not C, so ...
« Last Edit: September 13, 2015, 04:13:53 pm by Krozark »