j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
540 stars 32 forks source link

[Feature] No "bits/stdc++.h" in macOS/clang #138

Closed w43322 closed 1 year ago

w43322 commented 1 year ago

Verify steps

Description

bits/stdc++.h is a gnu/gcc extension, which is not present in macOS/clang.

https://stackoverflow.com/questions/28994148/how-can-i-include-bits-stdc-in-xcode

Should we fix this rather than letting the users fix this for themselves?

Possible Solution

#ifndef __APPLE__
    #include <bits/stdc++.h>
#else
    // insert #include directives here, or make a copy of gcc's bits/stdc++.h
#endif
j178 commented 1 year ago

Since we are emulating the LeetCode OJ, I think we should ship the bits/stdc++.h for macOS version. Like this one: https://github.com/tekfyl/bits-stdc-.h-for-mac/blob/master/stdc%2B%2B.h

w43322 commented 1 year ago

I agree. Should I make a separate PR or should I include it in #137 ?

j178 commented 1 year ago

It's better to create a separate PR.

w43322 commented 1 year ago

We can use this command to fetch the latest stdc++.h directly from gcc's source repo: git archive --remote=git://gcc.gnu.org/git/gcc.git HEAD libstdc++-v3/include/precompiled/stdc++.h | tar -xO

j178 commented 1 year ago

One question, if we include this file in our repo, do we have to change our license to GPL…

w43322 commented 1 year ago

What if we run this command on the user's machine?

j178 commented 1 year ago

What if we run this command on the user's machine?

I don't think we should do this automatically. Instead, we should add some instructions to our manual and let the users handle it themselves. Alternatively, we can simply have Mac users run brew install gcc :)