A simple question that Google doesn't help me with. Is it legal in C++ to use #elif
clause in the context of #ifdef
? It seems to compile and work as expected with all the major compilers in the c++11 mode (MSVC 2015/2017, clang, GCC), but I'm not certain whether it is standard-compliant.
Recap. Unless you're doing anything illegal, using a VPN in the U.S. is perfectly legally sound. However, if you're using a VPN in a country where it's not legal, it's important to download one of the best VPNs in terms of privacy.
Is It Legal to Use a VPN With Netflix? At the time of this writing, the US has no laws that make it illegal to use a VPN with Netflix. So although some people equate the use of a VPN to piracy, that's not the case at all. Piracy would be if you downloaded copyrighted material illegally.
If a VPN has IP leaks, DNS leaks, or WebRTC leaks, this could result in your online habits being tracked by your ISP. It will also allow online services and websites to detect your actual IP address. As a result, a leaky VPN is the easiest way to get caught out.
It isn't illegal to stream movies from legitimate streaming services while using a VPN (If VPNs are legal where you are). However, due to licensing issues, many streaming platforms like Netflix frown on this. In fact, some service providers will do their best to detect and block VPN users.
Yes, the grammar allows an #elif
after preceding, matching #if
, #ifdef
or #ifndef
:
if-section:
if-group elif-groupsoptelse-groupoptendif-lineif-group:
# if
constant-expression new-line groupopt
# ifdef
identifier new-line groupopt
# ifndef
identifier new-line groupopt
Note that #ifdef(X)
is just short for #if defined(X)
, and #ifndef(X)
for #if ! defined(X)
.
For me, the most important point on this question is actually rosshjb's comment under the question:
@RemyLebeau Yes, we can use #ifdef with #elif. But, If we #define macro with value 0 for #ifdef case, the #ifdef case tests it to true. Otherwise, if we #define macro with value 0 for #elif case, the #elif case test it to false. – rosshjb Jan 19 '20 at 19:40
So if you have a block like:
#ifdef __linux__
<some Linux code here>
#elif _WIN32
<some Windows code here>
#endif
Then the second test is significantly different from the first - the first is checking whether __linux__
is defined at all, where the second is checking that the symbol _WIN32
evaluates to true. For many cases it will behave the same, but it is not guaranteed to do so.
The full equivalent is actually:
#ifdef __linux__
<some Linux code here>
#elif defined(_WIN32)
<some Windows code here>
#endif
Which is probably not obvious to everyone.
Using Kerrick SB's answer, you can also write the same #if
statement as:
#if defined(__linux__)
<some Linux code here>
#elif defined(_WIN32)
<some Windows code here>
#endif
Which makes it more obvious that the defined
is the same for both the #if
and the #elif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With