用vs2010编译vlc报错如下:
问题一:
modules\access\file.c(632): error C2143: syntax error : missing ';' before 'const'
modules\access\file.c(633): error C2065: 'psz_localname' : undeclared identifier
modules\access\file.c(633): warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
modules\access\file.c(639): error C2065: 'psz_localname' : undeclared identifier
\file.c(632): error C2143: syntax error : missing ';' before 'const'的错误是由于ms vc2010认为C文件的变量定义没有位于函数的开始位置,这类错误没有别的办法,手工修改一下。
示例如下:
改动前
/*****************************************************************************
* OpenFile: Opens a specific file
*****************************************************************************/
static int _OpenFile( access_t * p_access, const char * psz_name )
{
access_sys_t *p_sys = p_access->p_sys;
#ifdef UNDER_CE
p_sys->fd = utf8_fopen( psz_name, "rb" );
if ( !p_sys->fd )
{
msg_Err( p_access, "cannot open file %s", psz_name );
return VLC_EGENERIC;
}
fseek( p_sys->fd, 0, SEEK_END );
p_access->info.i_size = ftell( p_sys->fd );
p_access->info.i_update |= INPUT_UPDATE_SIZE;
fseek( p_sys->fd, 0, SEEK_SET );
#else
#if defined (WIN32)
if( GetVersion() < 0x80000000 )
{
/* for Windows NT and above */
wchar_t wpath[MAX_PATH + 1];
if( !MultiByteToWideChar( CP_UTF8, 0, psz_name, -1, wpath, MAX_PATH ) )
{
msg_Err( p_access, "incorrect file name %s", psz_name );
return VLC_EGENERIC;
}
wpath[MAX_PATH] = L'\0';
p_sys->fd = _wopen( wpath, O_NONBLOCK );
goto opencont;
}
#endif
const char *psz_localname = ToLocale( psz_name );
if( psz_localname == NULL )
{
msg_Err( p_access, "incorrect file name %s", psz_name );
return VLC_EGENERIC;
}
p_sys->fd = open( psz_localname, O_NONBLOCK /*| O_LARGEFILE*/ );
LocaleFree( psz_localname );
opencont:
if ( p_sys->fd == -1 )
{
msg_Err( p_access, "cannot open file %s (%s)", psz_name,
strerror(errno) );
return VLC_EGENERIC;
}
#if defined(HAVE_FCNTL_H) && defined(F_FDAHEAD) && defined(F_NOCACHE)
/* We'd rather use any available memory for reading ahead
* than for caching what we've already seen/heard */
fcntl(p_sys->fd, F_RDAHEAD, 1);
fcntl(p_sys->fd, F_NOCACHE, 1);
#endif
#endif
return VLC_SUCCESS;
}
改动后:
/*****************************************************************************
* OpenFile: Opens a specific file
*****************************************************************************/
static int _OpenFile( access_t * p_access, const char * psz_name )
{
access_sys_t *p_sys = p_access->p_sys;
const char *psz_localname = ToLocale( psz_name );
#ifdef UNDER_CE
p_sys->fd = utf8_fopen( psz_name, "rb" );
if ( !p_sys->fd )
{
msg_Err( p_access, "cannot open file %s", psz_name );
return VLC_EGENERIC;
}
fseek( p_sys->fd, 0, SEEK_END );
p_access->info.i_size = ftell( p_sys->fd );
p_access->info.i_update |= INPUT_UPDATE_SIZE;
fseek( p_sys->fd, 0, SEEK_SET );
#else
#if defined (WIN32)
if( GetVersion() < 0x80000000 )
{
/* for Windows NT and above */
wchar_t wpath[MAX_PATH + 1];
if( !MultiByteToWideChar( CP_UTF8, 0, psz_name, -1, wpath, MAX_PATH ) )
{
msg_Err( p_access, "incorrect file name %s", psz_name );
return VLC_EGENERIC;
}
wpath[MAX_PATH] = L'\0';
p_sys->fd = _wopen( wpath, O_NONBLOCK );
goto opencont;
}
#endif
// const char *psz_localname = ToLocale( psz_name );
if( psz_localname == NULL )
{
msg_Err( p_access, "incorrect file name %s", psz_name );
return VLC_EGENERIC;
}
p_sys->fd = open( psz_localname, O_NONBLOCK /*| O_LARGEFILE*/ );
LocaleFree( psz_localname );
opencont:
if ( p_sys->fd == -1 )
{
msg_Err( p_access, "cannot open file %s (%s)", psz_name,
strerror(errno) );
return VLC_EGENERIC;
}
#if defined(HAVE_FCNTL_H) && defined(F_FDAHEAD) && defined(F_NOCACHE)
/* We'd rather use any available memory for reading ahead
* than for caching what we've already seen/heard */
fcntl(p_sys->fd, F_RDAHEAD, 1);
fcntl(p_sys->fd, F_NOCACHE, 1);
#endif
#endif
return VLC_SUCCESS;
}
问题二:
将
#define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),c,d, ## e )
修改为:
#define intf_UserFatal( a, c, d, e,... ) __intf_UserFatal( VLC_OBJECT(a),c,d, ## e )
More importantly, though, macros with variable numbers of arguments ("variadic macros") are not supported in C++; they exist only in C. If you're trying to compile this C code with a C++ compiler, the compiler should give you an error here because the code isn't legal C++.
问题三:
1>c:\program files\microsoft visual studio 10.0\vc\include\io.h(302): error C2373: 'closesocket' : redefinition; different type modifiers
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1617) : see declaration of 'closesocket'
believe you are getting these errors because windows.h will include winsock.h. Reverse the order of your includes so that WinSock2.h comes before windows.h. WinSock2.h has some #defines in it to keep windows.h from including winsock.h。