help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: causing side effects in user-defined functions


From: Brian Lewis
Subject: Re: causing side effects in user-defined functions
Date: Mon, 27 Nov 2006 01:56:15 -0600

On Mon, 27 Nov 2006 01:48:57 -0600
Brian Lewis <address@hidden> wrote:

> I'd like a user-defined function to say x="M"$(N), increment N, and
> return x. I know how to write user-defined functions, but I don't
> understand how they can cause side effects like the incrementing of
> the variable N. In case it isn't clear, this function would return M0
> the first time, M1 the second time, etc. User-defined functions in
> make seem functional. Maybe I can use semicolons? Is the value of a
> function the value of its last expression? Thanks.

This is what I came up with. I'm surprised it worked. Sorry for the noise.

generate_module_name = \
    x = M$(shell printf "%02u" $(CURRENT_MODULE_NUM)) \
    $(eval CURRENT_MODULE_NUM = $(shell expr $(CURRENT_MODULE_NUM) + 1)) \
    $(x)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]