C++ : File format error - c++

While compiling c++ code using vs 2005, i'm getting following mac file format related error. I couldn't find any reference in the internet for this particular error. Can someone help me regarding this.
error C4335: Mac file format detected: please convert the source file to either DOS or UNIX format
WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)

According to the MSDN:
The line termination character of the first line of a source file is Macintosh style (‘\r’) as opposed to UNIX (‘\n’) or DOS (‘\r\n’).
So just change line ending for your file. To do that, go File -> Advanced Save Options -> Set line endings to Windows.

Related

Eclipse RegExp Console Parsing Errors into Problems Window

Eclipse expert help needed! I have set up a makefile project to compile and link HCS12 code using the free codewarrior tools. It all seems to work well, but the only error/warning/information output I can get is to the console, with nothing being scanned from the console into the Problems window. I set up a regular expression error parser(Window -> Preferences -> C/C++ -> Build -> Settings -> Error Parsers) to scan the console for the appropriate information. If I search the console output (click in output and F) using find/replace with "regular expressions" checked, I find the warnings and errors--they just never get to the Problems tab.
I have enabled the error parser in (Project->Properties->C/C++ Build->Settings->ErrorParsers).
Somewhere I read that I need to enable this in C/C++ Makfile settings--but I cannot fine any settings which include the name "Makefile"; did I set up my project wrong??
Any suggestions or ideas on how to get my parsed errors into the problems window?
Eclipse Luna, Windows 7 professional.
It seems that the Regex parser for Eclipse (at least the older version I am currently using) assumes you start at the beginning of a line of text and end at the end of a line of text. My compiler errors were spanning multiple lines; I found a switch in the compiler which allowed it to output the errors in "microsoft format", which was then on a single line.
the new warning line looks like
.\CODE\LIBCODE\CodeLibraries\Drivers\CI2C1.C(312): WARNING C1801: Implicit parameter declaration for 'CI2C1_OnMasterBlockSent'
regex that works is now
[^"\n]\([^"(])((\d+)): WARNING C(\d+):([^\n]*)
of particular note is the [^"\n]*\ at the beginning of the regex expression, which matches all characters from the beginning of the line until the last \ is found--this is the piece I was missing. Eclipse Kepler is rather unforgiving about the regex it requires.
and we have
File $1 (just the file name--eclipse adds the path mysteriously if the file is in a code directory of the project)
Line $2 (gathers the line number of the error)
Descrioption $4 ( I ignore WARNING and the warning number, and capture the description of the error to the end of the line)
I now have a useful and somewhat more modern IDE to work with ancient code which grew from the assembly code over many years and was never parsed out into libraries or restructured into modern levels of abstraction.

Redirect c++ program syntax error to a file in windows

I'm using Dev C++ 5.11 on windows 10 home 64 bit. While compiling the program given below, I got the error message as semi colon is missing:
[Error] expected ';' before '}' token
I want the redirect or capture the syntax error in text file. I read about stdout and stderr, but couldn't get the output of compiler error in notepad/text file.
Unfortunately, there's no such option in the Dev-C++ IDE to redirect the output of stdout or stderr to a file.
But, you can do this from command line. This might help you in this regard:
How to redirect the output of gcc compiler to a file?
In addition, you can experiment with Tools -> Compiler Options to do this. I tried by adding general commands but it didn't work.
Alternatively, you can copy the warnings / errors by using Copy All option from context menu and paste it in a file manually.

AWS CodeDeploy ymal file error

I am deploying an application using AWS code deploy to Windows environment. I use an apspec.yml yaml file. When I deploy the application I get following error
The deployment failed because an invalid version value () was entered in the application specification file. Make sure your AppSpec file specifies "0.0" as the version, and then try again.
It seems like there is a problem with encoding or line ending. All the materials in the internet are for linux but not for windows. I use visual studio editor to edit this file. How to fix this issue?
In my case the encoding was wrong. appspec.yml should be saved as UTF-8 and not UTF-8 BOM.
BTW: The encoding can be changed in VS 2017 using File > Save as.., then the down arrow at the Save-Button ... Save with encoding...
The issue is in the line ending. If you create a yml file make sure you use \n line ending (linux way of line ending) instead of \r\n (windows way of line ending). If your editor is visual studio when you safe the yml file save it as follows.
File->Advanced Saved Options
Make sure your appspec.yml starts with below line
version: 0.0
codedeploy requires this attribute as must. refer this
Change the Encoding format by simply opening it notepad++ from UTF-8-BOM to UTF-8

How could I remove "error C4335: Mac file format detected" in VC 2008

I am now compiling a project with VC++ 2008, and the error I have obtained is as follows:
Error 7 error C4335: Mac file format detected: please convert the source file to either DOS or UNIX format
I was wondering how I could solve this kind of errors. I have found this link useful but the solution is suitable for VC++ 2010 rather than VC++ 2008. Any suggestion will be appreciated.
For VS2012 select and open the file within solution explorer. File->Advanced Save Options-> Set Encoding: Western European (Windows) && Set Line endings: Unix
You can use this addon to make the conversions automatically across your project, it's extremely easy.
Just save it in the format you want; VC+ 2008: http://msdn.microsoft.com/en-us/library/aad7fash(v=vs.90).aspx
You can open your file with Sublime Text, then open "View"->"Line Endings"->Unix/Windows. Then save the file.
Mac formatted files contain \r at the end of each line and that can cause in some cases compilation errors. Just remove the \r in each end of line and only use '\n' and try again. This warning should be then gone.
See also https://www.oreilly.com/library/view/mac-os-x/0596004605/ch01s06.html

DOS-reported error: Bad file number

I have a batch file that tries to compile a static library using Borland C++ Builder 6.0
It is called from Borland make (makefile created with bpr2mak) which is called from a .bat file (used to compile the whole project with Visual Studio and some Borland C++ Builder legacy projects), which is called from a bash shell script running inside Cygwin.
When I run the .bat file directly from a Cygwin shell, it runs OK, but when its being run from a Program calling cygwin with Boost::Process::launcher I'm getting this error:
C:\ARQUIV~1\Borland\CBUILD~1\Bin\..\BIN\TLib /u bclibs.lib #MAKE0000.###
DOS-reported error: Bad file number
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation
opening 'MAKE0000.###'
** error 1 ** deleting bclibs.lib
It's a complicated scenario, but this Program which calls cygwin is run whenever we need to build our software package which needs to be build for various Linux distos and Windows 32 and 64-bit.
Note: It's the only Borland Project failing, the other compile just fine (it's the only static library using borland also, so it can be some problem with the TLib tool.
The problem was that TLib does not like to have his output redirected (seen here) without having an input pipe as well. Solved by creating an input pipe to in the Boost::Process::launcher using set_stdin_behavior
I'm just guessing here, but this may have to do with long filenames and/or spaces in paths.
1) Modify your makefile so it would save current environment to a file, immediately before executing the failing command (set > d:\env.txt & echo CD=%CD% >> d:\env.txt). Then run it both ways (directly and via program) and compare the environments of good run and bad run.
2) Using filemon from Sysinternals, capture logs of disk access in both cases (these logs are going to be huge, though you can uncheck everything except Open in the filter to reduce the size). Again, compare and check for clues...
3) Try instaling everything involved to paths conforming to 8.3 scheme.
This error is not related to C++ itself. It happens when your build script opens too much files (more than defined in DOS command processor environment). To resolve this issue try to set value of files variable to 253. For Windows XP this variable defined in the file %WINDIR%\system32\config.nt.
files=253
Seems it is known bug in Borland C++ tools. Here is description and possible workaround for this issue:
Problem: Some static Lib projects will
not link correctly when compiled. You might see something
like this :
J:\Borland\CBUILD~1\bin\..\BIN\TLib /u debug\jpegD.lib #MAKE0000.###
DOS-reported error: Bad file number
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation
opening 'MAKE0000.###'
** error 1 ** deleting debug\jpegD.lib
MAKE failed, returned : 1
Workaround : In some cases (where the "Bad file number" error is seen) it may be possible to work around this by specifying -tDEFLIB.BMK in the BPR2MAKE Options field, and Turning off the "Capture Make Output" option.
I have not tested it, but I hope that helps.