MediaArea / MediaInfoLib

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://mediaarea.net/MediaInfo
BSD 2-Clause "Simplified" License
633 stars 173 forks source link

MediaInfo_Internal::SelectFromExtension at compiler limits #1903

Closed paulhiggs closed 10 months ago

paulhiggs commented 11 months ago

The method MediaInfo_Internal::SelectFromExtension in MediaInfo_File.cpp cannot be further extended.

When updating from

    #if defined(MEDIAINFO_AVSV_YES)
        else if (Parser==__T("AvsV"))        Info=new File_AvsV();
    #endif

to

    #if defined(MEDIAINFO_AVSV_YES)
        else if (Parser==__T("AvsV"))        Info=new File_AvsV();
        else if (Parser==__T("Avs3"))        Info=new File_Avs3();
    #endif

we get fatal error C1061: compiler limit: blocks nested too deeply for which a description can be found at https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1061?view=msvc-170. The proposed solution

To fix this error you must refactor your code. In any case, deeply nested code is difficult to understand and reason about.

Perhaps we need an lookup table rather than a large if ... else .... block!

JeromeMartinez commented 11 months ago

Perhaps we need an lookup table rather than a large if ... else .... block!

Right, we need something else than this ugly "if else", I'll find another way to do that.