Thread: int main (void) vs int main ( )

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Yeah, I'm of the opinion that compilers that treat an empty identifier list in a function definition placed before another function definition as meaning "no information about the number or types of the parameters is supplied" when the definition is taken as serving as a forward declaration are likely non-conforming, but in theory this is academic because identifier lists are obsolescent, which leads me to my rant:

    They didn't remove identifier lists in C17 even though there probably hasn't been new code written with non-empty identifier lists in over two decades, and my guess is that's because there's plenty of new code that uses empty identifer lists in function definitions or mistakenly in forward declarations to mean "no parameters". At some point they should admit that this is a mess that could be cleaned up by simply removing identifier lists and re-introducing empty identifier lists as a special case having semantics identical to void parameter type lists.

    It'll upset those who have continued to use empty identifier lists in forward declarations to mean "no information about the number or types of the parameters is supplied", but that hasn't been good practice for awhile, and you get no sympathy for having the rug pulled from under you when you insist on using a feature that has been obsolescent for over two decades.
    Last edited by laserlight; 04-04-2020 at 05:37 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bit confused about void main() vs int main()
    By pyroknife in forum C Programming
    Replies: 9
    Last Post: 01-08-2013, 02:53 AM
  2. [DEBATE]int main VS void main?
    By sudox in forum C++ Programming
    Replies: 20
    Last Post: 11-26-2010, 03:18 PM
  3. Why do people still use main() or main(void)?
    By Christopher2222 in forum C Programming
    Replies: 18
    Last Post: 06-06-2007, 06:34 PM
  4. A question about void(main) and int(main)
    By edd1986 in forum C Programming
    Replies: 2
    Last Post: 03-05-2005, 03:18 PM
  5. void main(), int main(), argc, argv[]????
    By Jonny M in forum C Programming
    Replies: 3
    Last Post: 03-06-2002, 09:12 AM

Tags for this Thread