Fix compilation error on CentOS 7 (gcc 4.8)#22313
Conversation
libstdc++ that comes with gcc 4.8 doesn't define `getline(basic_istream<char>&&, std::string&)` even if it's part of the c++11 standard. However we can still use the following: `getline(basic_istream<char>&, std::string&)`.
|
@hzcyf what do you think? |
|
Hi @mateusztabaka, thanks for your contribution! I have a question about the code: std::getline(std::ifstream(video + "/device/interface"), uvcDev.name);was parsed as the |
@mateusztabaka Thanks for your test and contribution! I have tested this PR on ubuntu18.04 with GCC7.5, it‘s running well! Sorry for my bad English! |
|
hi @zihaomu. That's interesting, I can see the same behavior that you mentioned with a simple snippet put into compiler explorer: https://gcc.godbolt.org/z/3fcEbaz5M. Also similar behavior I see for gcc >= 6.1. However with no optimizations
|
There was a problem hiding this comment.
LGTM!👍
With this path, it can pass GCC 4.8 successfully.
Passed case: https://gcc.godbolt.org/z/KjbWc156b
|
Can this be merged or should we wait for someone else's approval (I can see that Alexander Alekhin is on vacation)? |
|
@alalek, this fixes compile problems on CentOS, which is super-popular in some orgs. Can we merge it quickly? |
libstdc++ that comes with gcc 4.8 doesn't
define
getline(basic_istream<char>&&, std::string&)even if it's part of the c++11 standard.
However we can still use the following:
getline(basic_istream<char>&, std::string&).Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.