Skip to content

error: redeclaration of 'foo' cannot add 'dllexport' attribute #55329

Open
@lhmouse

Description

@lhmouse

If a function is declared without dllexport and called, but is later defined with dllexport, clang generates an error. GCC does not suffer from this issue (the attributes are merged, as if all declarations had dllexport).

void
foo(void);

void
bar(void)
  {
    foo();  /* the error goes away if this call is deleted  */
  }

__declspec(dllexport)
void
foo(void)  /* test.c:3:28: error: redeclaration of 'foo' cannot add 'dllexport' attribute */
  {
  }
E:\lh_mouse\Desktop>clang --version
clang version 14.0.0
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/MSYS2/clang64/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions