From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id DE8DD3858D3C for ; Fri, 2 Dec 2022 14:57:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DE8DD3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x62c.google.com with SMTP id ud5so12133734ejc.4 for ; Fri, 02 Dec 2022 06:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/M8Ps75QZEKGvtvU+K7y/hfTpdJvADIqJH7wUBwRPlQ=; b=VWFO3w6VW8Q2CmQd+//mgBtJA42oJAafByy4Uz6tKrAyUNf5F4P3qb8PfkoJFtIOW4 nFTrUhrwY5m1jTaBvD7qQVn8VV6uj3NLIUzACKsIDRH5jTtFUIgCaWXopmyUbncUEdga 12r/ZoIYnEBGrCdelMR6uauK/nC8RPXC8RCNVB24A2vy8lGohb7z6gzk0jD6MjJt/Knj JmzY9bEF9TsSygw+0jbGeAA67nrzmOGnPWotLAD5ZthCFxIbZ2nnPXFwWilGuYFXe2kl 7Jc0hkMq/ULI3Y8cX5Mm1ceRP9DUZPjIBYONsTkooVDPOHVFibc9gR596+ENSpEc+V9u eB4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/M8Ps75QZEKGvtvU+K7y/hfTpdJvADIqJH7wUBwRPlQ=; b=s54cCTIlN7pkes86YaWHc/t9mm1S/nRM6MFk2cAFNfaTgGkUfdeMztI+oCY0x2agNq uE/XR6NjXecOlsCKAPJannq6XeZmx/pbWnTLqYNxqpWnhQyse4IpYbEVwvn2bGOCDgU5 9fWeU3Ltb6PQF7C2lyhLZTROxsAlGjEPsYT/qpoch0VHxHKRJaYxbMeejLlM5/4uEiaF AvpiKZGB48tJgNKb+NVaIRSIYh25ArL7lTviXLDq4fhcI4hlx+8f4/E/+DGMzPhD/oSl QmsyLDQl/fhjEFdVmN7hnDxQQ90/jsRn96qwj05hemyI0QgH+4PS+Tde3lJdpy33+mBH 7jAw== X-Gm-Message-State: ANoB5pmHM8whxSEdhOuxI/vzWN52b033Kv4bxNTbTuYnRSIXtEFR5B5G 54uYBLYp1ZMOSXQle6DmgrGYBOiVn3JaqQ== X-Google-Smtp-Source: AA0mqf4PtguyxIVmx+Ugx5CFUJAo3S/C6Z6XAQrZSEX3oKbxa7fFEeTKLfQctGHF+Hp5mOqU5+MHYw== X-Received: by 2002:a17:906:9497:b0:7c0:cbc9:ab68 with SMTP id t23-20020a170906949700b007c0cbc9ab68mr1577737ejx.155.1669993066513; Fri, 02 Dec 2022 06:57:46 -0800 (PST) Received: from dhcpf166 ([185.137.144.10]) by smtp.gmail.com with ESMTPSA id la24-20020a170907781800b0078d4ee47c82sm3079847ejc.129.2022.12.02.06.57.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 06:57:46 -0800 (PST) From: =?utf-8?B?SmnFmcOtIFdvbGtlcg==?= To: gcc@gcc.gnu.org Subject: Feature request: Warning when .c file gets #include'd Date: Fri, 02 Dec 2022 15:57:44 +0100 Message-ID: <87359xyhsn.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, I've met a guy that is learning C and got stuck when the linker produced a screenful of messages about that he did something define multiple times. The cause of the problem was trivial: He did ``#include "something.c"'' in his code. In the past, I also did this thing multiple times and I would appreciate a warning produced by the gcc when compiling C/C++ file that includes a file ending in .c, .cx, .cpp or .cxx. What do you think about that? I would prefer to make this enabled when -Wextra is used. Based on my past experience with using .c files in the include directive, I can think of these problems. - Sometimes, I want to include a file that is definitely not a header, but also it is not a stand-alone source file. I personally prefer using .inc suffix, but some people possibly terminate the file names with .c suffix like a source file. Example: list of enum fields included from a separate file that was generated by a script - In some projects, someone can deliberately want to include another source file. For example, this can happen when doing unit tests and you do not want to specify the source file name on the command line. If you accept that, I can try to implement that. (That would be my first contribution to this project and I do not know gcc codebase, but it looks like a relatively simple change.) Do you think that it would need a copyright assignment? Thanks, Ji=C5=99=C3=AD