From MAILER-DAEMON Thu Apr 21 20:36:43 2022 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nhhHv-0005Tu-R9 for mharc-avr-gcc-list@gnu.org; Thu, 21 Apr 2022 20:36:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhh0T-0007Pv-Qb for avr-gcc-list@nongnu.org; Thu, 21 Apr 2022 20:18:41 -0400 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]:46596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhh0S-0002te-7e for avr-gcc-list@nongnu.org; Thu, 21 Apr 2022 20:18:41 -0400 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-2edbd522c21so69217407b3.13 for ; Thu, 21 Apr 2022 17:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=xg1bSUM3/D4nBROj4yUiULJ4gckVue477JJ9BVUu5K4=; b=AR6xRw+hNjfU/zSjXQZXkNPIXj37jxH9ZSFZp2Ugqz8DigLVVhHtuOcmM1//SkzvHM VZLrk/l2jLERAYWusc6hI1YPw59DC2pa1PUGCkzKaUz6QmtyKsYCsEzJ3hcP09nUC87U 3C8xAgCJp/Y/dOnih6PW1LJn5aalnh92ULWVLRy/YG9EQEsWz09j0P2Ul9Gz61tPN/WJ iKcBW1W26yhby+QlKwAolTEKTikSlmOG17l71PG0UVqJPI7b8MA1m341Gu4k5OiwkjPf MfVmmRuF8bmm/Iwuq5ITEKe+hUNEmcsPlo2IRIy34d6RHcCW25IkjjYCP1ObDX4eO7E2 W+oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=xg1bSUM3/D4nBROj4yUiULJ4gckVue477JJ9BVUu5K4=; b=UIsQT/Ot21eGEnAOd4BywNRytyWtGdhiCfQwVup8C2feXOVzswbZLg1vg7BNk+xY3Q l3tX6YYMKkn6NjDOlMzbIcYxXg8U86yuG1pWaVHVTnUDXikn9ZGBzSs2qzdcxLn/8LcO dgiA68NIHQYRr2R+kTYJMutI5QVZekAKRzKtpphY3g4/Fh1Ita0ii+Xf75omwk2hLPVP Q7vQAcxbl0+6DKUJUwNzhcQvcxYCnzVWjv9dJzlOk4PoZarNcm5RUMNbnsJKEBy7ZOfO zr3997zDFDETX3UjiltiLyLWJ168lqazgaql8sIur5Xpy5IsxAb/H0z5ScRgMW6RmwU2 /QxA== X-Gm-Message-State: AOAM5331QysQU7L4X4WPC8CyciNfZm3pIh9SlXzK7Km6y5FUXfxi4Sfn nokZqBqihIljHp9x05rtj1lEHWGI0C4jnsYD+t9F86FmSHtxpQ== X-Google-Smtp-Source: ABdhPJxFe3QWqYPr52n8ES9xAEhjG8jKCS5yL0JfoxO3RBR7hklNQCeCi9On99wOH1BHsDLSRxu0SV+QejbLYzlBuIA= X-Received: by 2002:a81:9a48:0:b0:2ec:2236:d325 with SMTP id r69-20020a819a48000000b002ec2236d325mr2471076ywg.386.1650586718591; Thu, 21 Apr 2022 17:18:38 -0700 (PDT) MIME-Version: 1.0 From: Ivan Perez Date: Thu, 21 Apr 2022 20:18:02 -0400 Message-ID: Subject: tgmath.h To: avr-gcc-list@nongnu.org Content-Type: multipart/alternative; boundary="000000000000085e5d05dd332b0d" Received-SPF: pass client-ip=2607:f8b0:4864:20::112b; envelope-from=ivanperezdominguez@gmail.com; helo=mail-yw1-x112b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 21 Apr 2022 20:36:42 -0400 X-BeenThere: avr-gcc-list@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the AVR-GCC toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2022 00:18:42 -0000 --000000000000085e5d05dd332b0d Content-Type: text/plain; charset="UTF-8" Hi, I'm trying to compile a program for arduino that relies on tgmath.h to pick the right version of a function based on the types (the code is automatically generated by another tool). It's failing to compile with avr because tgmath.h is missing. I thought it was part of the standard C distribution since C99 and thus I'd be able to rely on it, but I'm no C expert. Does anyone know why it is not included in avr-libc? Any advice? I'm on Ubuntu 20.04, using: avr-libc 2.0.0+Atmel3.6.2-1.1 gcc-avr 5.4.0+Atmel3.6.2-1 binutils-avr 2.26.20160125+Atmel-3.6.2-2 Thanks, Ivan --000000000000085e5d05dd332b0d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I'm trying to compil= e a program for arduino that relies on tgmath.h to pick the right version o= f a function based on the types (the code is automatically generated by ano= ther tool).

It's failing to compile with a= vr because tgmath.h is missing.

I thought it w= as part of the standard C distribution since C99 and thus I'd be able t= o rely on it, but I'm no C expert. Does anyone know why it is not inclu= ded in avr-libc? Any advice?

I'= m on Ubuntu 20.04, using:
avr-libc 2.0.0+Atmel3.6.2-1.1
gcc-avr 5.4.0+Atmel3.6.2-1
binutils-avr 2.26.20160125+Atmel-3.6.= 2-2

Thanks,

Ivan
--000000000000085e5d05dd332b0d-- From MAILER-DAEMON Fri Apr 22 05:22:35 2022 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nhpUm-0005S0-JL for mharc-avr-gcc-list@gnu.org; Fri, 22 Apr 2022 05:22:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhpUj-0005Qg-Nu for avr-gcc-list@nongnu.org; Fri, 22 Apr 2022 05:22:30 -0400 Received: from spam01.hesby.net ([81.29.32.152]:55282 helo=spam02.hesby.net) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhpUg-0004hk-Kl for avr-gcc-list@nongnu.org; Fri, 22 Apr 2022 05:22:28 -0400 Received: from [192.168.0.63] (unknown [79.161.10.130]) by spam02.hesby.net (Halon) with ESMTPSA id afa6ac95-c21d-11ec-920b-506b8dfa0e58; Fri, 22 Apr 2022 11:22:12 +0200 (CEST) Message-ID: Date: Fri, 22 Apr 2022 11:22:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: tgmath.h Content-Language: en-GB To: Ivan Perez , avr-gcc-list@nongnu.org References: From: David Brown In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=81.29.32.152; envelope-from=david.brown@hesbynett.no; helo=spam02.hesby.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: avr-gcc-list@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the AVR-GCC toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2022 09:22:30 -0000 On 22/04/2022 02:18, Ivan Perez wrote: > Hi, > > I'm trying to compile a program for arduino that relies on tgmath.h to > pick the right version of a function based on the types (the code is > automatically generated by another tool). > > It's failing to compile with avr because tgmath.h is missing. > > I thought it was part of the standard C distribution since C99 and thus > I'd be able to rely on it, but I'm no C expert. Does anyone know why it > is not included in avr-libc? Any advice? > > I'm on Ubuntu 20.04, using: > avr-libc 2.0.0+Atmel3.6.2-1.1 > gcc-avr 5.4.0+Atmel3.6.2-1 > binutils-avr 2.26.20160125+Atmel-3.6.2-2 > > Thanks, > > Ivan You are right that has been part of C since C99. But it is not part of C++, which is what the Arduino tools use. has macros for type-generic maths functions, and was originally implemented with compiler-specific extensions. With C11, the "_Generic" feature can be used to make compiler-independent implementations of the functions. In C++, function overloading has existed from the beginning, and is done in a completely different way. (Indeed, in C was invented to give C programmers the convenience C++ users already enjoyed for their maths functions, but made in a C-style manner.) So for your C++ code, you should use , not , and otherwise the usage will be the same. (You might need a "using namespace std;", but the Arduino IDE likes to confusingly hide such detail.) From MAILER-DAEMON Tue Apr 26 08:20:50 2022 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1njKBT-00013c-JC for mharc-avr-gcc-list@gnu.org; Tue, 26 Apr 2022 08:20:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njKBO-00012v-ED for avr-gcc-list@nongnu.org; Tue, 26 Apr 2022 08:20:43 -0400 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]:40261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njKBH-0001h1-B2 for avr-gcc-list@nongnu.org; Tue, 26 Apr 2022 08:20:41 -0400 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-2f7ca2ce255so80496087b3.7 for ; Tue, 26 Apr 2022 05:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hKkJbMUIA9XBx/00Tf2Mees75NCNJ7LOx0OvCSS+/n0=; b=ffhZq7HM/duDcKIUG/zx3o1LWVrsPR0QXCl26QBIy4urbIEpApnyDP0LPUwuMXf/ue trkjuvoQzR4st5e/GOn++XE2iCSPPs+5UyIfqgfaMNlNfBW333fksxEMrBEqfhQmcLAz oWXOTyTTIpG+NpnfRn+fSEWWUTrx1iPzvMcOVvjt8h58ogjVPjq7XfPUX12rgcXNXzwk 5O9Jt8PmiVIsi5Cym0etojxhxBSHgvXozapdiJdYAGOJ5C1ww14LGQyVrn3FFUvNPSWk UYFdxV6jCm4pUq0h87riB6iJDY8PoHBCF1UWwtQRr2AddE3VCn/LHdacL/uQCFTY0tS0 1H1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hKkJbMUIA9XBx/00Tf2Mees75NCNJ7LOx0OvCSS+/n0=; b=UtpB3j3OnBChfLwBiSIGcuP0t3oyP5XmWFx2LhGE+9Hf5MiWuqf0lxX0t5IR4T06D4 YuUhztvTScKURsIP/LNOjJIcx39H2xuhHMlY8m5LiM2Xi8OAxPEneFA4IH8kudwEonhx L66Dfzap1H/QIcjtVXIr6qHkbYvCXWLQlmqWNeCBRHsD1yYEgGZ5zy3r7K9oAx+qaxvR 2SdUWCIe5+FOHsKivkX99Gyxg/1bSdVPAWW1GyutOFkKaOCcmEKU7Y9nWo0cXZTkcGhV 8MvHYDE9xCIZAY6I+i4zftGzUJcbhsNKKgtDFdlJwH9+r3vj8VXALKl7znAW+mPiOwoA GlOg== X-Gm-Message-State: AOAM5332ZV3679BKdKJAlzwJKERwHomRQz9avTGhoEkEwhDqqnn1zdoY fsV6aKS1VcN9a+pTIKBSs3T11eLPwa3VR2+AWdc= X-Google-Smtp-Source: ABdhPJxIusXPoMc60d7Gbx3unnMgrK0DLXXgiJnQNUTo+jNdo6vAuxGmhFxGQpUSfp4Hg71uwFfkczW8U34qkV4mqjs= X-Received: by 2002:a81:3841:0:b0:2ec:3bb6:3101 with SMTP id f62-20020a813841000000b002ec3bb63101mr22254651ywa.476.1650975633272; Tue, 26 Apr 2022 05:20:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ivan Perez Date: Tue, 26 Apr 2022 08:20:22 -0400 Message-ID: Subject: Re: tgmath.h To: David Brown Cc: avr-gcc-list@nongnu.org Content-Type: multipart/alternative; boundary="0000000000002772fe05dd8db892" Received-SPF: pass client-ip=2607:f8b0:4864:20::1129; envelope-from=ivanperezdominguez@gmail.com; helo=mail-yw1-x1129.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: avr-gcc-list@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the AVR-GCC toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2022 12:20:43 -0000 --0000000000002772fe05dd8db892 Content-Type: text/plain; charset="UTF-8" Thanks!! This is very helpful! The hope is to generate the same C99 code regardless of the platform. So we need to use a math library that will work across platforms and deliver consistent behaviour. Ivan On Fri, Apr 22, 2022 at 5:22 AM David Brown wrote: > On 22/04/2022 02:18, Ivan Perez wrote: > > Hi, > > > > I'm trying to compile a program for arduino that relies on tgmath.h to > > pick the right version of a function based on the types (the code is > > automatically generated by another tool). > > > > It's failing to compile with avr because tgmath.h is missing. > > > > I thought it was part of the standard C distribution since C99 and thus > > I'd be able to rely on it, but I'm no C expert. Does anyone know why it > > is not included in avr-libc? Any advice? > > > > I'm on Ubuntu 20.04, using: > > avr-libc 2.0.0+Atmel3.6.2-1.1 > > gcc-avr 5.4.0+Atmel3.6.2-1 > > binutils-avr 2.26.20160125+Atmel-3.6.2-2 > > > > Thanks, > > > > Ivan > > You are right that has been part of C since C99. But it is > not part of C++, which is what the Arduino tools use. has > macros for type-generic maths functions, and was originally implemented > with compiler-specific extensions. With C11, the "_Generic" feature can > be used to make compiler-independent implementations of the functions. > In C++, function overloading has existed from the beginning, and is done > in a completely different way. (Indeed, in C was invented to > give C programmers the convenience C++ users already enjoyed for their > maths functions, but made in a C-style manner.) > > So for your C++ code, you should use , not , and > otherwise the usage will be the same. (You might need a "using > namespace std;", but the Arduino IDE likes to confusingly hide such > detail.) > --0000000000002772fe05dd8db892 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks!! This is very helpful!
The hope is to generate the same C99 code regardle= ss of the platform. So we need to use a math library that will work across = platforms and deliver consistent behaviour.

Ivan

On Fri, Apr 22, 2022= at 5:22 AM David Brown <dav= id.brown@hesbynett.no> wrote:
and replacing it with with explicitly named functions for different sized parameters. Alternatively, use a common C++ subset and drop the C99 requirements (again, dropping , replacing it now with ). There's a lot to like with Arduino - its relatively easy to use, and there is a lot of sample code and tools that let you get proof of concepts working quickly. But it has its disadvantages, and its non-standard language and oversimplification of the underlying compiler is a problem for more advanced usage. David On 26/04/2022 14:20, Ivan Perez wrote: > Thanks!! This is very helpful! > > The hope is to generate the same C99 code regardless of the platform. So > we need to use a math library that will work across platforms and > deliver consistent behaviour. > > Ivan > > On Fri, Apr 22, 2022 at 5:22 AM David Brown > wrote: > > On 22/04/2022 02:18, Ivan Perez wrote: > > Hi, > > > > I'm trying to compile a program for arduino that relies on > tgmath.h to > > pick the right version of a function based on the types (the code is > > automatically generated by another tool). > > > > It's failing to compile with avr because tgmath.h is missing. > > > > I thought it was part of the standard C distribution since C99 > and thus > > I'd be able to rely on it, but I'm no C expert. Does anyone know > why it > > is not included in avr-libc? Any advice? > > > > I'm on Ubuntu 20.04, using: > > avr-libc 2.0.0+Atmel3.6.2-1.1 > > gcc-avr 5.4.0+Atmel3.6.2-1 > > binutils-avr 2.26.20160125+Atmel-3.6.2-2 > > > > Thanks, > > > > Ivan > > You are right that has been part of C since C99.  But it is > not part of C++, which is what the Arduino tools use.  has > macros for type-generic maths functions, and was originally implemented > with compiler-specific extensions.  With C11, the "_Generic" feature > can > be used to make compiler-independent implementations of the functions. > In C++, function overloading has existed from the beginning, and is > done > in a completely different way.  (Indeed, in C was > invented to > give C programmers the convenience C++ users already enjoyed for their > maths functions, but made in a C-style manner.) > > So for your C++ code, you should use , not , and > otherwise the usage will be the same.  (You might need a "using > namespace std;", but the Arduino IDE likes to confusingly hide such > detail.) >