From patchwork Sat Feb 3 16:48:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45994 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a28:b0:199:de12:6fa6 with SMTP id cj40csp1644429pzb; Sat, 3 Feb 2024 08:53:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFUp5yAU7RRqdgnNGdSKZasbxGt8nol7Em/qpIhIJlQX9ufkVUHhZRB6b0k1CI/pKZvMEs X-Received: by 2002:aa7:c688:0:b0:55f:f13b:9b62 with SMTP id n8-20020aa7c688000000b0055ff13b9b62mr1706919edq.2.1706979181989; Sat, 03 Feb 2024 08:53:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706979181; cv=none; d=google.com; s=arc-20160816; b=KKXqz7DNz3jgISvvbQuBpjespQS5q+PY+pM/Lly/jNaJTdwFTNIcLRprWhwumHdsw3 rRBcz62+IrzQySnle8bDshRBMw0o43wtGscGuyxnRHus6Ug2q0xCPwoJsg28RnUNeP9n H47l0IoFCWZwHcOdedi8O3A5A0Coda36DvWWAR/On8BVYuY+l/qO5rescEZ26UYzQGB6 Za9XLG4X3GrCA9yYWKUuKFbbQKayPd9uxCexbF+FUIKnYOjSTscRAuefFWfeF8Ksew0P ItYK8xWDNXThPNIyxmASFC2K9UzneaJnvhxTqJ6bjzt5yJcZA5U6dnjSTRMisobqpJtN T7vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=xF+24voq3OByKHriT57esHZVsYLS9ddkxPHjIiCEsWg=; fh=KhFHjsFYYVcrrYXI5QI8IRWLQbSov9vwiul1wjCt+Uo=; b=aLZh5OJldBUr24kFtoZWiVYhUjgSYh/ctiPoEyvi92vIa5jTIxdsNn0SB46w+1j9lN h1MPNZEqSE28dg3y1slPwJLttBWcvkFbZz8522Hv/u3cEM8wJkyro10AtSFqoRJDOURA iIG01DOvxea3bqkCRqeQ5ODsvaaHAOUXyVgbVixTEbv7rwXJS1arCC9pM8fy9Kn/cUuQ HYDpsO7J3ZjMwk1OmgeQf1/1Lh9v2huQXZ+XVK6DgSE9ux3gd+RTAJBv1XLNsI/obzhM mjZecpEHwzfKaYMYbOAg/9pWFWc0yJykjfyCify2gRsCF/1AgNB89bwAjmlp8FnZuAkT z3vQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=NfV1amPB; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org X-Forwarded-Encrypted: i=0; AJvYcCWO8GDG02bJpZkyn+ElIpabotuPPZMOxKoYZIDx5ixhUshDPdoUyn/58qTCfwNA53jsbW02yu0tMjs0d8Evci/a33RlNhp3wGPKxE2LCJaTONxISMOJw2hDkyzO+OXGa8XDTbN818+1sThs6BPqpMTi+ZRNV3VAjaPmzJdzsX6E0GbkgyVU73PaNCqyDrMIM5oxy4gnrQ4LBZ4dwlgAudkNcSk4m/+KZDZRXdKIhbHOpbkGz3+U1lvPV/GXiyjxURRTrdMBMnaVW2tjYI3hBhmep4p4kzvssLWsRXNjEJ6HdsdAiJaN+06KWoZr9jmnU3xUOGzjmvETtB3wHhOZoDe4T5znrWcRaxAh0H7Y+BXcD8fzuAAutFsPJVxcgErSoophpWGyfimUXYDW7uvdueGp2EF3tDY57avPOv4xrlJB9JlEXl3sB0tkmUOtEsUOBqPFUKbhi/j0VYcgbTtnMDu/PuKr2C54eI/GfnWGTvr7Ee45gejIHj1H0+gLifOG30x6auyohmio2F/v9OKmxr21WkPXZOq0kHP4HNLxU0TGAKwmmCC73gdNaXryOLjP3zrhjhp5gl0/AnGrdRn/Wddva3JNgfUswAO+7xPU9lYmSpZftZe1uYwNeE1rGFH6EvACfTiQpeqY2KzgZx/LHxqYBShc0YcNibXeMik5bvxfD4E/l1XXyaNHcYuGeep6q1b+bINgTdoXJPWbbQh1ACW5xro0go1aO1Qmk+Vy1cf+ekv2+BYn057ZYs8Ig4jmqecVYehYgL4NnCG5xx6/9NkPkAtzIvFghJkqIsp70C9ZddWTu88OJycBWaGQlM2gnV4op+ReQIz4q3E8ypaK41dTkoOsBZhS1Eg/DRXziZb4DkisklmCohyHx1W750Tox4OJcQ+suJopxkSMstGNQA1E16hYL93sjiFSVgbGhNYKdpAPNrFd+zZzhiaauPnS5KYpTo RHiI6cb5lU5K+MABVSK6ywrPuQbGCoAog9aM9V/ME72oxgZWbKhmkqFfhpws+qg5PUWmqBkzDuqG0gbcobzQ+VcEd9HLSbmud8IduLQ9uqM89Xv16gKpdC9VyR12Sd4+wEcpS5CXEyXMTVFyCNxkkduX8pNCjwY/asUzppdXDs5644Y6v8yv0p1OgokYTS8Yyxo0T4s+dO0P4NyaI2HVNWBluNPF84ndadus0rEIlj9IIJL8D621I4QFpUzGdRJEZl5OVBVXlTg94iZh7FmmnCyJKU5NnXblYpmv6SIwt9csbfMkFazrik2Z7da11DB5sTckOF64oZDVHHbjIE/3hrynrWho19W9KcHCEvgB6Mx7Ma1wv5HTsz4AArmAAZHZ085paJws66e2+pLWNkCMamYgCvNZJuVZ1c438ir2ka3V4XLGoV3A2mnJqgvlumU6ObUDWRibZs4PgzyDBAoEL93JmSu2znkPXA4t2+dgEqe/FbY/LamOQ6qjvg0pp78HzTtu/hr4KTDNe6YqF4UmOvivvINB3S1l7/5M/fJP0pBzhXoBFtZnh61ApA6xp9xYfg5v3BRiv5BaYVGKanCfpBL3ItrYznibILT//tqC6c Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a9-20020a509b49000000b0055df856084esi2009742edj.686.2024.02.03.08.53.01; Sat, 03 Feb 2024 08:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=NfV1amPB; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D16B168D0DD; Sat, 3 Feb 2024 18:52:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B91268BCDC for ; Sat, 3 Feb 2024 18:52:50 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=NfV1amPB; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id A947A10FE for ; Sat, 3 Feb 2024 17:52:49 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 9F7rQk7r9VzO for ; Sat, 3 Feb 2024 17:52:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706979168; bh=plho8xG3z5UF26m3zuHHsmAAPpXtjvMHmdhz1v0bS/U=; h=From:To:Subject:Date:From; b=NfV1amPBWhGwHs3i7n+O3C6h17VPCLspRY2Gw+95USwSUWWwYkBFisJfJAmwhxf0L VLOI3v1XF0JDvZh4Ph+wnAlTZEYo3q9QGy/elUn7FsuCFtLwxs7kDS2XxwSjQByIfH L88ZeG0cqFfbMyR08QgLvETZIdmNHmiFs+Zd7/FP9S9OMVYrSuWOnF0ybexmj+DCd7 bGA4QIDgD1ROyFMzvaIOGUGarIy2HB2T8tvupkQHPQa7lNMGCycVgtFGRyzmYKQlYg jeNpx15VxgC3GGgHi1F25dxMOjMyyGS1muvKEcAUaWnzVklj17KBzIrDbS1pzVjvuI m+p+4my22aOjA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 3E7B081C for ; Sat, 3 Feb 2024 17:52:48 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8CB303A0435 for ; Sat, 3 Feb 2024 17:52:39 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Feb 2024 17:48:14 +0100 Message-ID: <20240203165220.21004-1-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [RFC/PATCH] Require compilers to support C11. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qeOTL5YjOVtn It should be available in all relevant modern compilers and will allow us to use features like anonymous unions. --- As discussed at the developer meeting at FOSDEM, and also in various places before that. The main blocker until now was MSVC, which should now support C11. Only tested on Linux with GCC/clang, so more testing is welcome. --- configure | 19 +++++++++---------- doc/developer.texi | 10 ++-------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 68f675a4bc..ae340b703b 100755 --- a/configure +++ b/configure @@ -4702,7 +4702,7 @@ msvc_common_flags(){ # generic catch all at the bottom will print the original flag. -Wall) ;; -Wextra) ;; - -std=c*) ;; + -std=c*) echo /std:${flag#-std=};; # Common flags -fomit-frame-pointer) ;; -g) echo -Z7 ;; @@ -4747,7 +4747,7 @@ icl_flags(){ # Despite what Intel's documentation says -Wall, which is supported # on Windows, does enable remarks so disable them here. -Wall) echo $flag -Qdiag-disable:remark ;; - -std=c99) echo -Qstd=c99 ;; + -std=c11) echo -Qstd=c11 ;; -flto*) echo -ipo ;; esac done @@ -4795,7 +4795,7 @@ suncc_flags(){ athlon*) echo -xarch=pentium_proa ;; esac ;; - -std=c99) echo -xc99 ;; + -std=c11) echo -xc11 ;; -fomit-frame-pointer) echo -xregs=frameptr ;; -fPIC) echo -KPIC -xcode=pic32 ;; -W*,*) echo $flag ;; @@ -4884,8 +4884,8 @@ probe_cc(){ _type=suncc _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-) _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)' - _DEPFLAGS='-xM1 -xc99' - _ldflags='-std=c99' + _DEPFLAGS='-xM1 -xc11' + _ldflags='-std=c11' _cflags_speed='-O5' _cflags_size='-O5 -xspace' _flags_filter=suncc_flags @@ -5514,21 +5514,20 @@ if test "$?" != 0; then die "C compiler test failed." fi -add_cppflags -D_ISOC99_SOURCE +add_cppflags -D_ISOC11_SOURCE add_cxxflags -D__STDC_CONSTANT_MACROS check_cxxflags -std=c++11 || check_cxxflags -std=c++0x # some compilers silently accept -std=c11, so we also need to check that the # version macro is defined properly test_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" && - add_cflags -std=c11 || - check_cflags -std=c99 + add_cflags -std=c11 || die "Compiler lacks C11 support" check_cppflags -D_FILE_OFFSET_BITS=64 check_cppflags -D_LARGEFILE_SOURCE -add_host_cppflags -D_ISOC99_SOURCE -check_host_cflags -std=c99 +add_host_cppflags -D_ISOC11_SOURCE +check_host_cflags -std=c11 check_host_cflags -Wall check_host_cflags $host_cflags_speed diff --git a/doc/developer.texi b/doc/developer.texi index eed0ee4915..c86bb5820c 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -56,14 +56,8 @@ and should try to fix issues their commit causes. @section Language -FFmpeg is mainly programmed in the ISO C99 language, extended with: -@itemize @bullet -@item -Atomic operations from C11 @file{stdatomic.h}. They are emulated on -architectures/compilers that do not support them, so all FFmpeg-internal code -may use atomics without any extra checks. However, @file{stdatomic.h} must not -be included in public headers, so they stay C99-compatible. -@end itemize +FFmpeg is mainly programmed in the ISO C11 language, except for the public +headers which must stay C99 compatible. Compiler-specific extensions may be used with good reason, but must not be depended on, i.e. the code must still compile and work with compilers lacking