[vlc-devel] [PATCH] npapi: Changed files to be compilable by VC.

Rafaël Carré funman at videolan.org
Mon Nov 21 07:26:01 CET 2011


Le Mon, 21 Nov 2011 12:37:11 +0700,
Sergey Radionov <rsatom at gmail.com> a écrit :

> 21.11.2011 10:42, Rafaël Carré пишет:
> > Le Mon, 21 Nov 2011 10:03:39 +0700,
> > Sergey Radionov<rsatom at gmail.com>  a écrit :
> >
> >> btw, I think macros HAVE_CONFIG_H not needed anymore, at least to me...
> >
> > Yes it was never needed.
> > config.h is always present in the source.
> >
> > We use it in VLC because files can be built outside of VLC build dir.
> >
> > Some questions:
> >
> > - Can you comment on npolibvlc.cpp change?
> +#ifdef _MSC_VER
> +const NPUTF8 * const LibvlcDeinterlaceNPObject::propertyNames[] = {
> +    ""
> +};
> +const int LibvlcDeinterlaceNPObject::propertyCount=0;
> +#else
>   const NPUTF8 * const LibvlcDeinterlaceNPObject::propertyNames[] = {
>   };
>   enum LibvlcDeinterlaceNPObjectPropertyIds {
>   };
>   COUNTNAMES(LibvlcDeinterlaceNPObject,propertyCount,propertyNames);
> +#endif //_MSC_VER
> 
> problem is that VC not able create zero length arrays.
> so we need create array with some dummy item (it can be any string, including zero lengh string, or 
> simply NULL, it does not matter), but propertyCount set to 0, to satisfy original logic.
> 
> anticipating you next question, I say  that we must define propertyNames and propertyCount, as 
> LibvlcDeinterlaceNPObject used in templates that need it.

Ok, if a dummy array works, we might as well use it in all cases to avoid #ifdef hell
Just add a comment saying why we do that.
e.g. // MSVC++ doesn't support zero length arrays, as of version XXXX

> > - mingw-w64 also includes npapi.h (I guess mingw32 is just broken), but
> > gcc fetches npapi.h from the correct path if we give it with -I
> 
> In visual studio (at least in VS2008 and early), paths to libs usially not defined directly in 
> solution, but it defines in IDE. But IDE already have path to Windows SDK in the first place, so 
> SDK's npapi.h founded first. But we can't move gecko sdk to first place in IDE, as then we can broke 
> compilation of other projects than include npapi.h from Windows SDK.
> So we need include some header with unique name, that include npapi.h by self.

Ha I see npfunctions has a #include "" and not <>

Same than above, just use npfunctions everywhere with
// Include npfunctions to avoid including Windows' own npapi.h

> > - why do you need config.h at all? It only contains the const or not
> > const prefix for the function which recently changed prototype.
> In VS solution I make substitution of original config.h by my own config.h, which now is:

Hm right you had explained that already sorry.

You could add -Dsnprintf=_snprintf and likes to the VC project but if we need more config 
options it will soon get very long so I am not sure what's the best to do.

> //config.h begin
> #pragma once
> #define snprintf _snprintf
> #define strcasecmp _stricmp
> 
> /* Wether NPP_GetMIMEDescription returns const */
> #define NPP_GET_MIME_CONST const
> //config.h end

-- 
Rafaël Carré



More information about the vlc-devel mailing list