Cpp default parameters exposed to swift?

I have a function that has the following declaration in cpp.

Shape ConnectHorizontal(const Key& left,
                        const Key& right,
                        Shape connector = GetPostConnector(),
                        double offset = 0);

However when I try to use it from swift with only the first two params, I get an error.

scad.ConnectHorizontal(key_thumb_0_5, key_thumb_0_4)//missing arguments for parameters #3, #4 in callsourcekitd , glm_extensions.swift(408, 35): 'ConnectHorizontal' declared here (__ObjC.scad)

Workaround is to declare in CPP as overloads.

Shape ConnectHorizontal(const Key& left,
                        const Key& right,
                        Shape connector,
                        double offset);
Shape ConnectHorizontal(const Key& left,
                        const Key& right);
1 Like