Developer Forum

How to format OSL code?

I have basically finished developing the code for Fractal Voronoi Noise but I’m stuck at how to properly format it.

As for the C and C++ files I simply ran Clang format as the Developer Wiki recommends. But now I’m left wondering what I should do about the OSL files.

The files certainly look like they have been formatted, but trying to run Clang format on OSL files in Visual Studio gives the error that “the command (Format Document) is not currently available”.

If I change the file to a C++ file and run Clang format afterwards the resulting code is formatted differently than what Blender uses for OSL files.

So how do you format OSL code?

If the ide integration is misbehaving, you can try running make format from the source folder

Thanks for the tip. Does OSL also use Clang format or something different?

it uses clang format from the libs folder, which could be a different version from whatever your ide internally uses, it’s recommended always to submit patches using make format