HydrogenAudio

Hosted Forums => foobar2000 => Development - (fb2k) => Topic started by: TheQwertiest on 2019-06-28 16:43:36

Title: fb2k SDK problem: C++ compliance in headers
Post by: TheQwertiest on 2019-06-28 16:43:36
Some PFC headers fail to compile with `/permissive-` flag (C++ standard conformance):
Code: [Select]
pfc\list.h(236,1): error C2664:  'void pfc::list_base_t<T>::sort(void)': cannot convert argument 1 from 'pfc::list_base_t<T>::sort_callback_impl_t<t_compare>' to 'pfc::list_base_t<T>::sort_callback &'
This is caused by passing temporary variable to a method that accepts only non-const reference argument, which is prohibited by C++ standard.

Since this header is included (transitively) in the components that uses PFC, it prevents such components to be built in C++ conformance mode (which is required for some other libraries like `range-v3`)

Possible fix implementation: https://github.com/TheQwertiest/pfc/commit/1610e1ac450d9d1c16a139afe73c8743b12f4ac8
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: TheQwertiest on 2019-06-28 16:51:34
@Peter : FYI
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: TheQwertiest on 2019-06-28 19:46:17
Other C++ conformance issues: https://github.com/TheQwertiest/foobar2000-sdk/commit/966c454c23a6cd91d8689fd68a48799a3949be7e

Another temporary passed as non-const reference argument + ambiguous call in template method (doesn't work with two-phase name lookup).
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: Peter on 2019-06-28 19:49:09
Noted, thanks for reporting.

... not like the SDK is really meant to work on anything else but MSVC and these are typical MSVC-isms, but they will be addressed anyway.
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: TheQwertiest on 2019-06-29 14:35:51
... not like the SDK is really meant to work on anything else but MSVC and these are typical MSVC-isms
Well, MS have been working pretty hard last few years on making MSVC C++ conformant. This work resulted in the following flags (among other things): `/permissive-` (which is now on by default in new projects), `/experimental:preprocessor`,  `/experimental:newLambdaProcessor` (both of which are planned to be on by default, once all the kinks are ironed out). Some of these are required by popular cross-platform C++ libraries, since they are relying on correct C++ behaviour.
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: Peter on 2019-06-29 20:54:59
Please keep in mind that foobar2000 still supports Windows XP.

Whether to support XP in your component is up to you, but if you do, your Platform SDK won't compile with /permissive- anyway.

I'm working in ironing all these out for the next update.
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: TheQwertiest on 2019-10-22 16:26:47
@Peter :
Another compliance issue that I've encountered (after updating to VS 2019 16.4 Preview 2.0):
`Use of the class in a template before it's declaration`.

Repro steps:
- Download latest fb2k SDK.
- Open it in VS specified above.
- Change all projects to use v142 compiler.
- Enable C++14 and enforce C++ compliance in `foo_sample` (C++ > Language > Conformance mode > Yes; C++ > Language > C++ Language Standard > C++14).
- Compile the project.

Error output:
Code: [Select]
Error C3861: 'service_factory_base': identifier not found; foo_sample: foobar2000\SDK\service.h: 458

This is easily fixed by forward declaring `class service_factory_base` before (or inside) `service.h`.

Related MSVS issue (with link to explanation of this new behaviour): https://developercommunity.visualstudio.com/content/problem/782516/vs2019-1640-preview-2-problems-with-permissive-and.html

PS: Thanks for fixing all previously mentioned issues!
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: TheQwertiest on 2019-12-04 10:28:39
VS 2019 16.4 was released, so the issue described above will be present on any CI that have updated their images.
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: Peter on 2019-12-27 13:05:13
New SDK posted, /fpermissive- issues in service factory headers have been addressed.
Title: Re: fb2k SDK problem: C++ compliance in headers
Post by: TheQwertiest on 2020-01-17 09:45:02
New SDK posted, /fpermissive- issues in service factory headers have been addressed.
Yup, everything compiles fine now, thanks!