Login Page - Create Account

Support Board


Date/Time: Thu, 28 Nov 2024 10:57:18 +0000



[Programming Help] - ACSIL help with max()

View Count: 309

[2023-05-15 10:54:24]
User92573 - Posts: 530
Dear Support Board

I'm hoping someone can help with this error message.


How can ...

int& iGetMax = sc.GetPersistentInt(1);

iGetMax = max(2,3,4,5); // I'm expecting the largest element, iGetMax = 5.

Produce " warning C4002: too many actual parameters for macro 'max'"

Obviously a simple error but not sure why it's occurring.

Any help appreciated.

Many thanks
[2023-05-15 16:25:31]
Tony - Posts: 522
I believe both min() and max() only take 2 parameters, in your example, you had 4 parameters.
[2023-05-15 16:41:39]
User431178 - Posts: 544
You can nest it
iGetMax = max(2,max(3,max(4,5)));

[2023-05-16 07:58:19]
User92573 - Posts: 530
Many thanks to both of you. I hadn't realised it was limited to 2 elements and I didn't want to iterate for a small number, so max() seemed ideal except I had misunderstood it's structure.

Your assistance and StackExch clarified.

Many thanks

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account