Semicolon after curly braces in C ++

I recently started working with the vtk package, and I see this odd notation that they include ;after closing curly braces }. Here is an example fromvtkUnstructuredGrid.h

// Description:
// Standard vtkDataSet API methods. See vtkDataSet for more information.
int GetDataObjectType() {return VTK_UNSTRUCTURED_GRID;};

It is not needed, and QtCreator also correctly defines this, saying extra ;when parsing the code. I'm curious what could be causing this? Maybe readability?

+5
source share
2 answers

As QtCreator correctly defines, this is definitely an optional semicolon that is not only useless, but can also cause compiler warnings and confusion.

For example, a GCC with a flag -Wpedantic will run :

warning: extra ';'

+1
source

. ++ ;. int GetDataObjectType();. , : int GetDataObjectType() {}; , : return VTK_UNSTRUCTURED_GRID;, , , , .

0

All Articles