CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    37

    Did rules for naming your files change?

    Years ago when I was writing C++ code I remember you could not name a source file with spaces between the words. For example this was not allowed:

    Hot Pancakes

    You had to do this:

    Hot_Pancakes

    Or this...

    HotPancakes

    Now I'm writing some code again in C++ Builder and the program allows me to do this:

    Hot Pancakes

    So I'm wondering if they made changes to C++ along the way?

  2. #2
    Join Date
    Oct 2008
    Posts
    1,456

    Re: Did rules for naming your files change?

    source file naming has never been part of the c++ specification; how #include<> or #include"" directives are interpreted ( both in terms of file location and character encoding ) is and always has been implementation defined ( the only exception being the standard headers ).
    Last edited by superbonzo; September 3rd, 2017 at 10:25 AM.

  3. #3
    Join Date
    Feb 2017
    Posts
    677

    Re: Did rules for naming your files change?

    Quote Originally Posted by 357mag View Post
    Years ago when I was writing C++ code I remember you could not name a source file with spaces between the words Hot Pancakes.
    Most C++ implementations don't care how you name a file as long as the file can be found in the file system. This means it's the naming convention of the operating system that decides what is a valid file name. In Windows it's this,

    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    So what you have noticed is because you are using a newer OS this time that is more liberal on file names.

    Note that Windows doesn't allow <, > nor " to be part of file names. This of course is to avoid clashes with the syntax of the #include command. So even though C/C++ doesn't care what a file name looks like it still influences what a file name better looks like.
    Last edited by wolle; September 4th, 2017 at 04:26 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured