Re: I want to use the g++ template in the "C" gcc software

Liste des GroupesRevenir à cl c  
Sujet : Re: I want to use the g++ template in the "C" gcc software
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c
Date : 12. Dec 2024, 11:24:04
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vjedk4$22uqf$2@dont-email.me>
References : 1
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 12/12/2024 09:37, aotto1968 wrote:
Hi,
 I create a C software and there is a requirement to use the g++ template *in* the gcc.
I do *not* want to use all the g++ "boilerplate" like special syntax, classes etc
I just want to use the template.
 goal:
 1. I already use "inline" code to replace "cpp-macro-like" syntax in the header.
2. NOW I *want* to replace a "cpp-macro" which use the *data-type* as an argument with a template.
 question.
 1. Is there a g++ switch to disable all the g++ features except of C source and template feature ?
2. Is there a gcc switch to add g++-template feature into gcc ?
3. is there an external software to add the c++-template feature into an existing C software ?
 thanks.
It might help if you give an example of what you are trying to achieve - it doesn't have to be valid code that can be compiled.
gcc has command-line options to disable some features of C and C++, but not like you are describing.  And C++ without classes is not the same as C anyway.  But you might find you can write your code in C++ and simply not use the features you don't want to use.
If you are trying to make type-generic function-like "things" in C, then you have to use macros.  But you can use modern features of C11 and C23 to make this safer and neater than in older C standards.  gcc also provides extensions that can help, if you are happy writing gcc-specific code.
You should do your own googling for information, tutorials and examples here, but these links will give you some starting points:
C11 _Generic selections:
<https://en.cppreference.com/w/c/language/generic>
C23 "typeof" and "auto" type inference:
<https://en.cppreference.com/w/c/language/typeof>
<https://en.cppreference.com/w/c/language/auto>
gcc extensions:
<https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html>
<https://gcc.gnu.org/onlinedocs/gcc/Typeof.html>

Date Sujet#  Auteur
12 Dec 24 * I want to use the g++ template in the "C" gcc software11aotto1968
12 Dec 24 +- Re: I want to use the g++ template in the "C" gcc software1Bonita Montero
12 Dec 24 +* Re: I want to use the g++ template in the "C" gcc software4David Brown
12 Dec 24 i`* Re: I want to use the g++ template in the "C" gcc software3aotto1968
12 Dec 24 i `* Re: I want to use the g++ template in the "C" gcc software2Chris M. Thomasson
12 Dec 24 i  `- Re: I want to use the g++ template in the "C" gcc software1Kaz Kylheku
12 Dec 24 +* Re: I want to use the g++ template in the "C" gcc software3Kaz Kylheku
12 Dec 24 i+- Re: I want to use the g++ template in the "C" gcc software1aotto1968
12 Dec 24 i`- Re: I want to use the g++ template in the "C" gcc software1Chris M. Thomasson
12 Dec 24 `* Re: I want to use the g++ template in the "C" gcc software2Chan
13 Dec 24  `- Re: I want to use the g++ template in the "C" gcc software1Keith Thompson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal