vs2010编译VLC问题

     用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。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值