Welcome to the Builder Academy

Question MSDP Inventory

More
13 Nov 2017 14:02 #7087 by JTP
Replied by JTP on topic MSDP Inventory
Do you also get the same warnings ?

Must be a better way to do it, maybe Thomas or someone else has an idea ?

Please Log in or Create an account to join the conversation.

More
14 Nov 2017 01:58 - 14 Nov 2017 01:59 #7088 by WhiskyTest
Replied by WhiskyTest on topic MSDP Inventory
Yeah I do, mine is:

comm.c:2997:34: warning: zero-length gnu_printf format string [-Wformat-zero-length]
It still compiles and works.

But I did a bit of googling and found this explanation:
"It's not harmful. It's just letting you know there's something questionable about your code, that you might have made a mistake. Although sprintf (str, ""); is legal, it's a rather round-about way of making str a zero-length string, and could indicate a logical error in your code. It's not forbidden; just brought to your attention." - Phil Perry on Stack Overflow website.

So more googling revealed that another way to do it is this:
Code:
buf[0] = '\0';
Which compiles without error - and is used in other parts of TBAmud code, so I think this is the better option.
Last edit: 14 Nov 2017 01:59 by WhiskyTest.

Please Log in or Create an account to join the conversation.

More
14 Nov 2017 06:22 #7089 by JTP
Replied by JTP on topic MSDP Inventory
So
buf[0] = '\0';

Instead of the line:
snprintf(buf, sizeof(buf), "");
?

There are only two remotely similar placed in my tbacode that says: *buf = '\0';

Please Log in or Create an account to join the conversation.

More
15 Nov 2017 19:18 #7093 by JTP
Replied by JTP on topic MSDP Inventory
Do you know Whiskey ?

Please Log in or Create an account to join the conversation.

More
15 Nov 2017 20:28 #7095 by WhiskyTest
Replied by WhiskyTest on topic MSDP Inventory
Yeah so replace snprintf(buf, sizeof(buf), "");
with
buf[0] = '\0';

That works and it compiles without warning. I've updated the original post with our findings
The following user(s) said Thank You: JTP

Please Log in or Create an account to join the conversation.

More
15 Nov 2017 20:56 #7097 by JTP
Replied by JTP on topic MSDP Inventory
So that was inventory, what about what is worn in eq ?

Please Log in or Create an account to join the conversation.

Time to create page: 0.194 seconds