r18955 - gnucash/trunk/src - MSVC compatibility: MSVC must not use g_fopen because it uses a different C runtime than the rest of (MSVC) file-handling functions.

Christian Stimming stimming at tuhh.de
Tue Mar 23 19:17:00 EDT 2010


Am Montag, 22. März 2010 schrieb Phil Longstaff:
> On Mon, 2010-03-22 at 17:15 -0400, Christian Stimming wrote:
> > Author: cstim
> > Date: 2010-03-22 17:15:15 -0400 (Mon, 22 Mar 2010)
> > New Revision: 18955
> > Trac: http://svn.gnucash.org/trac/changeset/18955
> >
> > Modified:
> >    gnucash/trunk/src/backend/xml/gnc-backend-xml.c
> >    gnucash/trunk/src/backend/xml/io-gncxml-v2.c
> >    gnucash/trunk/src/backend/xml/sixtp.c
> >    gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c
> >    gnucash/trunk/src/engine/TransLog.c
> > Log:
> > MSVC compatibility: MSVC must not use g_fopen because it uses a different
> > C runtime than the rest of (MSVC) file-handling functions.
> 
> If we're starting to get into conditional compilation based on
> compiler/platform,

I'm sorry about my above commit. This is still in experimental state - MSVC 
compiles, but it still doesn't run (because all the glib wrapped file-related 
functions use a C runtime which is different from the default MSVC one, and 
I'm still trying whether I can get along with changing our client code as 
opposed to having to recompile glib by MSVC).

> I think I'll introduce a scheme based on what webkit
> has.  Basically, there's a platform.h file which contains macros so that
> you can use:
> 
> #if COMPILER(MSVC)
> #if PLATFORM(WIN32)

The reason for using _MSC_VER (note the leading underscore) is that it is a 
macro which is internally defined by the MSVC compiler and only that one. As 
I've written on 
http://wiki.gnucash.org/wiki/CMake#Which_C_preprocessor_macros_tell_me_whether_I.27m_on_Windows_or_Linux.3F
- there are macros which exist solely on particular compilers and they always 
exist there. I'm not so happy with replacing them by hand-written other macros 
which are defined somewhere in our user code EXCEPT if we have to use that a 
lot inside of our code, but this is not the case right now.

In this particular commit the macro is used (intentionally) only in the 
section with the header files. I don't intent to use it throughout the code.

Best Regards,

Christian



> #if HAVE(ABC)
> #if USE(WEBKIT)
> #if ENABLE(FEATURE)
> 
> I think it looks a lot cleaner than what we have now (e.g. MSC_VER)
> 
> Phil
> 
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
> 



More information about the gnucash-devel mailing list