Skip to content

Linux: change to posix style#81

Closed
DimStar77 wants to merge 1 commit intovmware:masterfrom
DimStar77:posixly
Closed

Linux: change to posix style#81
DimStar77 wants to merge 1 commit intovmware:masterfrom
DimStar77:posixly

Conversation

@DimStar77
Copy link

replace it by defined(linux)

replace it by defined(__linux__)
@JonathonReinhart
Copy link

Care to elaborate on this change? Under what circumstances is __linux__ defined as opposed to linux?

@DimStar77
Copy link
Author

Sure.. nothing easier than that.

Take this very dummy c++ 'code':

#if defined(linux)
  #warning linux is defined
#endif
#if defined(__linux__)
  #warning __linux__ is defined
#endif

int main() {
  return 0;
}

then compile it twice, once using:

g++ test.cpp

test.cpp:4:4: warning: #warning linux is defined [-Wcpp]
#warning linux is defined
^
test.cpp:7:4: warning: #warning linux is defined [-Wcpp]
#warning linux is defined

And once using

g++ test.cpp -std=c++11
test.cpp:7:4: warning: #warning linux is defined [-Wcpp]
#warning linux is defined
^

Building using c++11 standard does NOT provide the linux defines...
and c++11 is mandatory nowadays when building against recent stack of libsigc++ / libglibmm

@JonathonReinhart
Copy link

Thanks @DimStar77. This was mainly for my own curiosity, but it may help get this PR merged, too. That is, if anyone from @vmware pays any attention to it.

@vmwclabot
Copy link

@DimStar77, you must sign our contributor license agreement before your changes are merged. Click here to sign the agreement. If you are a VMware employee, read this for further instruction.

@vmwclabot
Copy link

@DimStar77, VMware has approved your signed contributor license agreement.

@bzed
Copy link

bzed commented Jul 24, 2016

In the meantime compiling with -std=gnu++11 works well :)

@mikini
Copy link

mikini commented Nov 22, 2016

Confusing read! For anyone also puzzled by the thread above and maybe not looking at the patch, notice the text emphasized in bold and surround those with __. In the markdown formatting used here double underscore, as in the standard compiler defines, are translated into bold text unless marked otherwise.

Original PR text 'code' quoted:
replace it by defined(__linux__)

And the gcc output (my execution):

$ g++ test.cpp 
test.cpp:2:4: warning: #warning linux is defined [-Wcpp]
   #warning linux is defined
    ^
test.cpp:5:4: warning: #warning __linux__ is defined [-Wcpp]
   #warning __linux__ is defined
    ^
$ g++ test.cpp -std=c++11
test.cpp:5:4: warning: #warning __linux__ is defined [-Wcpp]
   #warning __linux__ is defined
    ^

Still unmerged though. Things busy at VMware?

@stanguturi
Copy link
Contributor

Thanks. We have created an internal bug to track it.

@DimStar77 DimStar77 closed this Sep 6, 2017
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.

6 participants