Win32 Port of Safari

Simon Hausmann hausmann at kde.org
Fri Jan 10 09:59:38 GMT 2003


On Thu, Jan 09, 2003 at 03:17:29PM -0600, Alan Gutierrez wrote:
> Stephan Johach wrote:
> > Hi!
> 
> > If you are using an MS C++ compiler older than VisualStudio.NET than be
> > aware that it's not very standard compliant in some cases.
> >
> > Example
> >
> > for (int i=0; i< 10; i++)
> > 	puts("Blah\n");
> >
> > printf("%d", i);
> >
> > VisualStudio prior to VS.NET compiles without even a warning. The variable
> > i is handled as if it was declared before the loop.
> >
> > int i;
> > for ( i=0; i<10; i++)
> > ...
> >
> > The standard says i is only valid in the scope of the for construct, so i 
> is
> > not declared for the printf().
> >
> > So expect more pitfalls. :)
> 
> Yup. Hit this twice. Each time I took moved the variable declaration out of
> the for initalization.
> 
> Really, the problems I encountered with the KHTML source have been minor. 
> I'm
> sure we are going to want to discuss how to resolve the differences between
> the two compilers, but VC++ isn't being *too* much of a baby. It doesn't 
> look
> like we are going to have to have excessive #ifdef nonsense.

One other bug with VC++ you're going to run into at run-time are
bitfields with enums. khtml makes extensive use of them, VC++
compiles code using it without saying anything but essentially
miscompiles it, causing memory corruption at run-time. What I did
with the win32 port of konq/e was to remove the bitfield
definitions. The other option is to change the variables to int and
do a lot of casting then. (the latter is definitely preferred in
terms of memory usage ;) but a lot more work and pretty ugly in the
end patch wise)

Simon




More information about the kfm-devel mailing list