Skip to content

#pragma once doesn't seem to be respected #645

@ds5678

Description

@ds5678

I'm working on bindings for LibTorch, and one of the issues I found while using ClangSharp on library.h is with #pragma once.

./include/torch/library.h:93:12: error: redefinition of '_RegisterOrVerify' ./include/torch/library.h:107:17: error: redefinition of 'CppFunction' 
./include/torch/library.h:340:20: error: redefinition of 'dispatch' ./include/torch/library.h:354:20: error: redefinition of 'dispatch' 
./include/torch/library.h:412:83: error: redefinition of default argument ./include/torch/library.h:421:55: error: redefinition of default argument 
./include/torch/library.h:431:30: error: redefinition of 'schema' ./include/torch/library.h:437:61: error: redefinition of 'constructSchemaOrName' 
./include/torch/library.h:441:61: error: redefinition of 'constructSchemaOrName' ./include/torch/library.h:446:1: error: redefinition of 'constructSchemaOrName' 
./include/torch/library.h:482:7: error: redefinition of 'ClassNotSelected' ./include/torch/library.h:499:7: error: redefinition of 'SelectiveStr' 
./include/torch/library.h:543:17: error: redefinition of 'Library' ./include/torch/library.h:934:7: error: redefinition of 'TorchLibraryInit'

It generates fine if I replace #pragma once with this traditional pattern:

#ifndef TORCH_LIBRARY_123_
#define TORCH_LIBRARY_123_

// Code

#endif // TORCH_LIBRARY_123_

As with any issue I post, I'm willing to make a pull request. However, I'm not sure where to start with this one and would appreciate some guidance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions