-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The glog outputs recently introduced in hdf5.cpp break compatibility … #3130
The glog outputs recently introduced in hdf5.cpp break compatibility … #3130
Conversation
…for some compilers (eg. MSVC) due to declaring a variable after a case label without its own scope. This commit fixes this problem by adding brackets to define a new variable scope after each case label. Further reading: https://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement
That's coming from #2978 - my bad. Can we catch this sort of thing with the TravisCI build matrix somehow? Or with lint? |
@lukeyeager There was an old effort to add other compilers (clang) to the build matrix but I have not collected enough interest. See #1218 |
For MSVC, most necessary changes are single lines that can easily be put into #ifdef blocks so they will not introduce new problems with gcc. I created the PR because in my opinion, that is a feature worth preserving. |
I think we should merge this PR, since it does not affect Linux or OSX users, while makes things easier for community windows ports. |
I'm actually interested in what changes are allowed to improve compiler compatibility. I've made a MSVC port in [1] and it can be seen, that most changes to the original code are not that big, although sometimes it's required to include custom compatibility headers. Negative effects for gcc users can be avoided completely by using #ifdef _MSC_VER . |
@MalteOeljeklaus I made a pull request #2816 to bring MSVC support in Caffe and core devs said that they would merge the PR provided that:
Although I'd rather have Caffe avoid non cross-platform code, I think your idea of libwincaffe is nice and in line with @shelhamer's comment above. At the time I submitted the PR I did not take special care to avoid unnecessary ifdefs. I think your work brings us closer to a least invasive possible solution. However, I feel that we should probably try to have a single (or a few) platform specific header where we would put the necessary ifdefs and include this file wherever we need it to avoid spreading The CMake based build could be useful here too to automatically pull and build libwincaffe using ExternalProject like is done with glog and gflags. I believe the most sensible approach to add support for other compilers such as MSVC, is to submit PRs that have the smallest number of changes possible to make review easier for the core devs like you did. As a side note you can have a look at caffe-builder a CMake based project I put together to build caffe and its dependencies easily. |
See #3365 (comment) which applies here as well. |
Closing in favor of the minimal change in #3365, but thanks for the fix! |
The glog outputs recently introduced in hdf5.cpp break compatibility for some compilers (eg. MSVC) due to declaring a variable after a case label without its own scope. This commit fixes this problem by adding brackets to define a new variable scope after each case label. Further reading: https://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement