Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6809805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:07:47+00:00 2026-05-26T20:07:47+00:00

On a whim, I tried to define the main function as a template function

  • 0

On a whim, I tried to define the main function as a template function using clang 2.9:

template <typename T = void>
int main(int argc, char **argv)
{
}

and received the following error.

error: 'main' cannot be a template
int main(int argc, char **argv)
    ^

Does anyone know what section of the standard forbids this, and what the relevant text is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:07:47+00:00Added an answer on May 26, 2026 at 8:07 pm

    Well, how about this (3.6.1):

    A program shall contain a global function called main, which is the designated start of the program. […] This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined.

    Since templates are not functions, I don’t think you have any choice in the matter. In particular, the function has to be main, not main<> as in your example; and your main isn’t a function, but a template, precluding the existence of another function called main.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a very simple ad button system using ASP.NET 2.0 The advertisment is
So I'm using jqGrid with my mvc.net / Ling2Sql prototype site that I'm making
Say instead of returning void a method you returned a reference to the class
UDPATE On a whim, I decided to upload the 4 fonts files to an
On a whim, I've decided to go back and seek certification, starting with 98-361,
I have an asp.net website where I'm using stylesheets. Problem is, when I went
For debug reasons, and on a whim, I'd like to include certain information in
I have two TFS branches that do not have a direct parent/child relationship in
Working on a project that uses some IronPython scripts to as plug-ins, that utilize
I have a classic asp webpage written in vbscript that outputs the results from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.