[FFmpeg-cvslog] Support building C++ files with MSVC
Aaron Levinson
git at videolan.org
Fri Apr 14 00:58:19 EEST 2017
ffmpeg | branch: master | Aaron Levinson <alevinsn at aracnet.com> | Thu Apr 13 02:38:02 2017 -0700| [bceb3d0f8621dd4dcdab2148e29d1473165d9cb6] | committer: Hendrik Leppkes
Support building C++ files with MSVC
Made appropriate changes to be able to successfully
build C++ files using a Visual C++ build on Windows.
Based on an earlier patch by Kyle Schwarz.
Comments:
-- compat/w32pthreads.h: Made appropriate changes to w32pthreads.h to
get it to build when it is being included in a C++ file and built
with Visual C++. This is mostly a copy of Kyle Schwarz's patch as
described above.
-- configure:
a) Now calling set_ccvars CXX to cause the various CXX_ variables to
be setup properly. For example, with MSVC (Microsoft Visual C++),
this causes CXX_O to be set to -Fo$@ instead of using the default
value. The default value does not work with Visual C++. This
change will also have the impact of correcting CXX_O (and possibly
CXX_C) for other compilers, although this is really only relevant
for the Intel compiler, in addition to MSVC.
b) Now using cl for the C++ compiler for the MSVC toolchain. This is
currently only relevant for building the
Blackmagic/Decklink-related files under avdevice.
Signed-off-by: Hendrik Leppkes <h.leppkes at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bceb3d0f8621dd4dcdab2148e29d1473165d9cb6
---
compat/w32pthreads.h | 14 +++++++-------
configure | 4 ++++
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 0c9a7fa13b..eeead6051f 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -77,7 +77,7 @@ typedef struct pthread_cond_t {
static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
{
- pthread_t *h = arg;
+ pthread_t *h = (pthread_t*)arg;
h->ret = h->func(h->arg);
return 0;
}
@@ -270,7 +270,7 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_
}
/* non native condition variables */
- win32_cond = av_mallocz(sizeof(win32_cond_t));
+ win32_cond = (win32_cond_t*)av_mallocz(sizeof(win32_cond_t));
if (!win32_cond)
return ENOMEM;
cond->Ptr = win32_cond;
@@ -288,7 +288,7 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_
static av_unused int pthread_cond_destroy(pthread_cond_t *cond)
{
- win32_cond_t *win32_cond = cond->Ptr;
+ win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr;
/* native condition variables do not destroy */
if (cond_init)
return 0;
@@ -305,7 +305,7 @@ static av_unused int pthread_cond_destroy(pthread_cond_t *cond)
static av_unused int pthread_cond_broadcast(pthread_cond_t *cond)
{
- win32_cond_t *win32_cond = cond->Ptr;
+ win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr;
int have_waiter;
if (cond_broadcast) {
@@ -337,7 +337,7 @@ static av_unused int pthread_cond_broadcast(pthread_cond_t *cond)
static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{
- win32_cond_t *win32_cond = cond->Ptr;
+ win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr;
int last_waiter;
if (cond_wait) {
cond_wait(cond, mutex, INFINITE);
@@ -369,7 +369,7 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu
static av_unused int pthread_cond_signal(pthread_cond_t *cond)
{
- win32_cond_t *win32_cond = cond->Ptr;
+ win32_cond_t *win32_cond = (win32_cond_t*)cond->Ptr;
int have_waiter;
if (cond_signal) {
cond_signal(cond);
@@ -397,7 +397,7 @@ static av_unused int pthread_cond_signal(pthread_cond_t *cond)
static av_unused void w32thread_init(void)
{
#if _WIN32_WINNT < 0x0600
- HANDLE kernel_dll = GetModuleHandle(TEXT("kernel32.dll"));
+ HMODULE kernel_dll = GetModuleHandle(TEXT("kernel32.dll"));
/* if one is available, then they should all be available */
cond_init = (void (WINAPI*)(pthread_cond_t *))
GetProcAddress(kernel_dll, "InitializeConditionVariable");
diff --git a/configure b/configure
index d01cb59d6d..98f7828489 100755
--- a/configure
+++ b/configure
@@ -3640,8 +3640,10 @@ case "$toolchain" in
cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
cc_default="cl"
+ cxx_default="cl"
else
cc_default="c99wrap cl"
+ cxx_default="c99wrap cl"
fi
ld_default="$source_path/compat/windows/mslink"
nm_default="dumpbin -symbols"
@@ -3852,6 +3854,7 @@ msvc_common_flags(){
-lz) echo zlib.lib ;;
-lavicap32) echo vfw32.lib user32.lib ;;
-lx264) echo libx264.lib ;;
+ -lstdc++) ;;
-l*) echo ${flag#-l}.lib ;;
-LARGEADDRESSAWARE) echo $flag ;;
-L*) echo -libpath:${flag#-L} ;;
@@ -4197,6 +4200,7 @@ cflags_noopt=$_cflags_noopt
add_cflags $_flags $_cflags
cc_ldflags=$_ldflags
set_ccvars CC
+set_ccvars CXX
probe_cc hostcc "$host_cc"
host_cflags_filter=$_flags_filter
More information about the ffmpeg-cvslog
mailing list