On Mon, 6 May 2019 at 23:09, Sudhindra kulkarni via cfe-users
<[email protected]> wrote:
>
>
> ---------- Forwarded message ----------
> From: "Tim Northover" <[email protected]>
> Date: May 1, 2019 3:48 PM
> Subject: Re: [llvm-dev] Overriding macro values defined in source code
> To: "Sudhindra kulkarni" <[email protected]>
> Cc: "LLVM Developers Mailing List" <[email protected]>
>
> On Tue, 30 Apr 2019 at 22:28, Sudhindra kulkarni via llvm-dev
> <[email protected]> wrote:
> > Is it possible to override the value of AVAL through the -D option?
> > For eg is it possible to set the value of AVAL to 2 through -D in clang ?
>
> This is more a question for the cfe-users list, but as far as I know
> there's no way to prevent redefinitions in source files.
>
> Cheers.
>
> Tim.
>
> Hi Team,
>                  Consider the below C code,
> #define AVAL 5
> void func()
> {
> int a=5;
> if(a==AVAL)
> {
> //Do something
> }
> else
> {
> //Do something else
> }
>
> }
> My question is
> Is it possible to override the value of AVAL through the -D option?
> For eg is it possible to set the value of AVAL to 2 through -D in clang so 
> that the else part executes?
> Also apart from -D option we are also open to other ways of achieving this

The normal approach is to change the source to something like

#ifndef AVAL
#define AVAL 5
#endif

> Thanks in advance
> _______________________________________________
> cfe-users mailing list
> [email protected]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
_______________________________________________
cfe-users mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to