Skip to content

Enum defined after a function template cannot be compiled #2525

@Ebola-Chan-bot

Description

@Ebola-Chan-bot

Describe the problem

C:\Users\vhtmf\AppData\Local\Temp\.arduinoIDE-unsaved202414-28316-jorhob.tu2i\sketch_feb4a\sketch_feb4a.ino:8:1: error: 'E' does not name a type
 E D()
 ^
C:\Users\vhtmf\AppData\Local\Temp\.arduinoIDE-unsaved202414-28316-jorhob.tu2i\sketch_feb4a\sketch_feb4a.ino:8:3: error: expected initializer before 'D'
 E D()
   ^

exit status 1

Compilation error: 'E' does not name a type

To reproduce

template<typename T>
void C(T F)
{}
enum E
{
  OS
}
E D()
{
  return E::OS;
}
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Expected behavior

I have verified this code in MSVC, and there should be no problem.

Arduino IDE version

版本:2.2.1 日期:2023-08-31T14:35:44.802Z CLI 版本:0.34.0 Copyright © 2024 Arduino SA

Operating system

Windows

Operating system version

版本 Windows 11 专业版 Insider Preview 版本号 23H2 安装日期 ‎2024/‎1/‎28 操作系统版本 26040.1000 体验 Windows Feature Experience Pack 1000.26040.1000.0

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

topic: build-processRelated to the sketch build processtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy