Why does the name of a source file affect compilation?

前端 未结 4 1043
逝去的感伤
逝去的感伤 2020-12-11 02:04

I came across something really weird when I wrote a little lotto program in C++ called \"lotto.cpp\". Everything was fine until I wrote the write-to-file for my program. Whe

相关标签:
4条回答
  • 2020-12-11 02:29

    Error number 21 (on MacOS X 10.7.2) is EISDIR: Is a directory.

    The name lotto seems to be a directory, not a file.

    0 讨论(0)
  • 2020-12-11 02:29

    This is a linker error that states that we cannot write to the 'lotto' file on your computer while compiling. My guess is that either your program is still running, or you accidentally created a directory called 'lotto'. It's possible that your write-to-file function is keeping the application running, or itself tried to create a lotto directory.

    0 讨论(0)
  • 2020-12-11 02:32

    FWIW I got this error when I was trying to write my output file into a directory that hadn't been created yet, i.e. bin/myprogram.

    Once I created the bin directory everything was fine; I didn't have to re-name anything. GCC seems to create the directory if it doesn't exist, whereas clang doesn't (at least thats as near as I can tell).

    0 讨论(0)
  • 2020-12-11 02:47

    Yeah I ran into this problem by copying some of my visual studio code to my mac. It seems Visual Studio likes to create folders inside your project with your executable name which causes this!

    0 讨论(0)
提交回复
热议问题