1

I have developed some code under Unix using Cgwin, Linux and HP-UX. Since I don't want to start from scratch when doing some Windows stuff, I wanted to compile the code with Visual Studio 2008. Of course I'm aware that I have to do some adaptions, regarding system specific functionality like using fcntl. What I didn not expect though, was that there seem to be also problems using standard functions like snprintf etc.

snprintf and Visual Studio 2010 or Error 4 error C3861: 'snprintf': identifier not found

Since there are also many other problems, I was considering using MingW. As far as I understood, MingW is a native Windows compiler right? So I still would have to port the systerm specific stuff, but I would like to know, if the move to MingW would give me any benefit by reducing the number of compatibillity issues.

I'm aware that this might be regarded as opnion based, but I don't want to compare MingW vs. MSVC, I just would like to know if the switch would reduce the porting issues, or if it is as waste of time and just as well stick to MSVC. I have ported code before, but always from Windows to Unix, which seems to have been much easier then the other way around.

Community
  • 1
  • 1
Devolus
  • 21,661
  • 13
  • 66
  • 113
  • The standard Windows runtime library doesn't have many functions that are otherwise standard. For example, instead of `sprintf` it has [`_snprintf`](http://msdn.microsoft.com/en-us/library/2ts7cx93.aspx). – Some programmer dude Jan 08 '14 at 10:10
  • @JoachimPileborg, yes, but when googling, it seemed that the beahviour is slightly different as well. So I would like to minimize such impact. Even here on SO I could find several postings dealing with that. And I guess there are others as well, not jsut snprintf. So I would like to know if MingW helps in that, as I don't reall know much about it, and googling didn't help much either. – Devolus Jan 08 '14 at 10:11

1 Answers1

2

As far as I understood, MingW is a native Windows compiler right?

If by native you meant Windows as a target OS, then yes. But if you were thinking about the building host - If you want so. MinGW is a GCC port, and can be built for Linux as well. Latest Ubuntu has both x32 and x64 versions of MinGW, for example.

I would like to know, if the move to MingW would give me any benefit by reducing the number of compatibillity issues.

Definitely yes. Using GCC port means you will need to solve only OS-dependent issues, and skip compiler and Microsoft library differences.

Andrejs Cainikovs
  • 27,428
  • 2
  • 75
  • 95
  • Thanks! `skip compiler and Microsoft library differences` This was the part I was rather unsure about and which I found rather annoying. Si I'll give it a try. Didn't want to waste time installing everything jsut to find the same issues again. :) – Devolus Jan 08 '14 at 10:55
  • 1
    Worth mentioning, that under *OS-dependent issues* my fall also behavior of some standard functions, like 'snprintf' in your case. – Andrejs Cainikovs Jan 08 '14 at 10:55
  • I always thought MingW would be a gcc package built for native Windows programming. So what does it mean if you say it is built for Linux as well? Are MingW and GCC different compilers then, only based on a similar code base? – Devolus Jan 08 '14 at 11:00
  • Thanks for pointing that out. Do youi know, are there many other problems with functions like `snprintf`? Is there maybe some list or guide available? – Devolus Jan 08 '14 at 11:12
  • I just was not sure what you meant by 'Native', and wanted to highlight that MinGW can be executed on Linux platform. Sometimes this is handy if you're baking a distro for multiple targets and have a Linux-based build machine in your possession. Regarding the port itself, I don't know how big is a difference between GCC and MinGW code-wise, sorry. – Andrejs Cainikovs Jan 08 '14 at 11:16
  • Also, I don't know if there are other problems with functions like `snprintf`, and I'm afraid there is no official list of functions that may act differently from platform to platform. But.. what I do know is that MinGW is community driven, and that they have a mailing list that may help you, which is not the case with Microsoft :) – Andrejs Cainikovs Jan 08 '14 at 11:23
  • Wow! That was really helpfull, because I just compiled all my code with the single exception of one function I have to port (which I knew anyway), opposed to getting hundreds of errors in MSVC. :) – Devolus Jan 08 '14 at 17:24