0

I'm trying to apply these patches:

http://tehsausage.com/mingw-to-string

So that I can use std string stuff that I should have access to anyways.

I have MinGW 4.7.2, and at first, I tried copying the zip files with no luck.

Now I'm trying to manually apply the patches. I copied the patch information into a file.patch, placed it in the same folder as the file I am patching, and ran

patch < file.patch

and then I get:

 patching file stdio.h
 patch unexpectedly ends in middle of line
 Hunk #1 FAILED at 574.
 patch unexpectedly ends in middle of line
 1 out of 1 hunk FAILED -- saving rejects to file stdio.h.rej
 patch unexpectedly ends in middle of line

I made sure that there is no extra white space at the end..

Please help!

Matt M
  • 149
  • 2
  • 4
  • 17
  • If you created the patch file using a dos editor, it may be missing the trailing line end. Use an editor like vim to make sure that there is a line end at the end of the file. Additionally, make sure that the file uses unix line endings – Anya Shenanigans Apr 13 '13 at 20:18
  • Did you try the patch yourself and does it work? If so, would you be kind enough to send me the patch files? – Matt M Apr 13 '13 at 20:41

2 Answers2

1

OK, installed the latest mingw from the web-site, downloaded the patch files and made sure they were clean.

I applied each one individually, and they worked without issue. There was a warning that it was 'Stripping the trailing CRs from the file', but it worked without issue.

each patch is applied in the appropriate directory; e.g. the stdio.patch is applied to stdio.h which is in /mingw/include using:

patch </path/to/stdio.patch

ditto for wchar.patch

The os_defines.h file is found at /mingw/lib/gcc/mingw32/4.7.2/include/c++/mingw32/bits, and the patch works properly for that one as well.

I created a github with the patches at https://github.com/petesh/mingwpatches.git - you can clone the repository, or download the individual files from there. Each of them should work correctly without more than a complaint about the trailing CR warning.

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
  • How do I download them? I'm only presented with the option of copying what's in them.. – Matt M Apr 14 '13 at 02:25
  • if you don't have github for windows, or poshgit, then you can click on the cloud icon that says zip, which downloads the files in a .zip file. Windows can open zip files natively. – Anya Shenanigans Apr 14 '13 at 09:19
  • Thanks. The files patched successfully and I replaced them in the correct folders. I restarted my machine and eclipse still will not allow me to use itoa or t_string. Any ideas?? – Matt M Apr 14 '13 at 15:06
  • Make sure that you have the compiler flag `-std=c++0x` set, otherwise the code will remain commented out, and thus unavailable. – Anya Shenanigans Apr 14 '13 at 22:09
  • How do I do that? Sorry for late reply. – Matt M Apr 15 '13 at 21:08
  • If you're using an eclipse project, then edit the project properties; go to `C/C++ Build` -> `Settings` -> `GCC C++ Compiler` -> `Miscellaneous`. In the `Other flags` box add `-std=c++0x`, making sure it applies to all configurations (otherwise it will compile in debug but not in release for example). If you're using a Makefile, then add `-std=c++0x` to the `CXXFLAGS` variable – Anya Shenanigans Apr 16 '13 at 07:56
0

After looking at the patch files, you probably need to use the -c option to the patch command. This tells patch that the patch-files are from a context diff.

E.g.

$ patch -c < file.patch
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621