"unexpected end-of-file found" issue on Precompile Header compilation with Visual Studio

I am trying to build a c++ project with precompiled header. When building, 2 files are created during the Prefix header file generation : prefix-headers.cpp and prefix-headers.h
Then when compiling these, the build task returns an error
pchGenerated\prefix-headers.cpp(1) fatal error C1004: unexpected end-of-file found
Trying to run manually the compilation command from the output.txt file, I am getting the same issue.
When adding manually a CR/LF to the prefix-headers.h , I am able to compile (manually).
Would it be possible to fix this by adding the newline in the file at the end of the file?
As a work-around, I would like to add myself the newline after the Prefix headers generation task, but I don’t really see how to make it. Advice would be welcome.
Thanks in advance

Would something like the following work?

tasks.withType(PrefixHeaderFileGenerateTask) { task ->
    task.doLast {
       task.prefixHeaderFile << "\r\n"
    }
}

Hi Gary,

I am now getting a CRLF in prefix-headers.h
How could I add a CRLF to the prefix-headers.cpp file too? It seems that it is blocking there too…

Yeah, the cpp file is only added for Visual Studio (gcc/clang don’t need it) so it gets created opaquely as part of the compile process. There’s not a good way to hook in and add a CRLF in between generation and compile for that particular file. What version of Visual Studio are you using? For some reason, we don’t have this issue with the versions we test with.

Regardless, looking at the description of the error on MSDN it looks like there is an expectation that source files should have a CRLF at the end of the file, so we should fix this in Gradle. Please file an issue at https://github.com/gradle/gradle/issues and we’ll get it fixed for the next version.

Thanks for reporting this!

Currently I am using Visual Studio 2012. What is strange to me is that when compiling the sample in gradle distribution, it works just fine. When compiling our project I get this issue.
I will raise an issue.
Thanks for your kind assistance!

I have raised the issue :