Community
Participate
Working Groups
Formatter->Line Wrapping->Function calls is configured to 'Wrap only when necessary' and 'indent on column'. Line Width is set to 80 characters. When the formatter is applied to a function prototype, similar to the following, it wraps as expected e.g. static uint16_t validateMessage (uint16_t numBytes, uint8_t * pMsg, bool ignoreSeq); When the formatter is applied for a second time the bool part of the prototype is then aligned to column 1 e.g. static uint16_t validateMessage (uint16_t numBytes, uint8_t * pMsg, bool ignoreSeq); The workaround is to define a new type e.g. BOOL_t and use this throughout the code rather than bool. Formatting is then retained on subsequent formats.
I can't reproduce this problem. I get the initial result you describe, and then it stays that way. Is this a C++ project or a C project?
Hi Nathan, Yes this is a C project. I tried this in Luna in Windows. I did not have quick keys enabled and so used the Source->Format menu to reformat this snippet. This did not exhibit this problem. Then I set Ctrl + Shift + F in Preferences->Keys: Command=format Binding=Ctrl+Shift+F When=In Windows Category=Source User=U
(In reply to John Anderson from comment #2) > Yes this is a C project. If it's a C project, how is "bool" defined? It's not a built-in type in C.
When I reapply the format using the quick keys then the problem arises. First time, format is ok and the second time its as explained earlier. Thanks Nathan for looking into this.
Bool is defined from <stdbool.h> which has is defined from _Bool. Interestingly, this problem does not arise if I use _Bool for the data type.
Nathan, I'm back with Mars in Debian this morning. I removed all quick keys for formatting and the problem still occurs. So my earlier may be a 'red herring'. The following snippet goes from this... for (i = 0; i < NUM_BINS; i++) { pMem[i] = (uint8_t *) malloc (MAX_RECORDS * MAX_RECORD_SIZE); pData[i] = (uint8_t **) malloc (MAX_RECORDS * sizeof(pData)); if (NULL == pMem[i] || NULL == pData[i]) { printf ("Failed to allocate memory for pData[] : %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__); abort (); } } to this... for (i = 0; i < NUM_BINS; i++) { pMem[i] = (uint8_t *) malloc (MAX_RECORDS * MAX_RECORD_SIZE); pData[i] = (uint8_t **) malloc (MAX_RECORDS * sizeof(pData)); if (NULL == pMem[i] || NULL == pData[i]) { printf ("Failed to allocate memory for pData[] : %s, %s, %d\n", __FILE__, __FUNCTION__, __LINE__); abort (); } }
Thanks, I can reproduce the issue now. I believe it's a duplicate of bug 459301.
Always great when its reproducible :). Good luck with fixing this.