Hi everybody,
I have issues with preprocessor indentation inside functions;
original:
void init(void)
{
#ifdef ENABLE && (ENABLE==1)
os_queue_create(&queue, "QUEUE", QUEUE_MESSAGE_SIZE, buffer, QUEUE_MAX_FILES * QUEUE_BYTE_SIZE);
#endif // #if defined(ENABLE) && (ENABLE==1)
}
bool add_file(char* filepath)
{
#ifdef ENABLE && (ENABLE==1)
int res;
int len;
len = strlen(filepath);
if (len>QUEUE_MESSAGE_SIZE)
return false;
res = os_queue_send(&queue, filepath, 100);
ASSERT(res==0);
if (res!=0)
return false;
return true;
#else
return true;
#endif
}
after astyle:
void init(void)
{
#ifdef ENABLE && (ENABLE==1)
os_queue_create(&queue, "QUEUE", QUEUE_MESSAGE_SIZE, buffer, QUEUE_MAX_FILES * QUEUE_BYTE_SIZE);
#endif // #if defined(ENABLE) && (ENABLE==1)
}
bool add_file(char* filepath)
{
#ifdef ENABLE && (ENABLE==1)
int res;
int len;
len = strlen(filepath);
if (len>QUEUE_MESSAGE_SIZE)
return false;
res = os_queue_send(&queue, filepath, 100);
ASSERT(res==0);
if (res!=0)
return false;
return true;
#else
return true;
#endif
}
the second function has a strange indentation, I tried with some options but it does not change.
This is my standard configuration:
AStyle version 3.6
--suffix=none
--style=allman
--indent=spaces=2
--indent-switches
--pad-comma
--lineend=windows
--preserve-date
--formatted
Thanks,
Marco
Hi, is there any code before this function to trigger this?
Hello @saalen,
yes, there are some rows of code:
I found the problem just now:
the comment after 16 value is with * and this brokes something with astyle, but doesn't with ide/compiler.
Without * astyle works fine!
Thanks anyway,
Marco
Hi Marco, adding a single space after
//also increases readability for humans. Therefore, many style guides prescribe this type of visual padding between the “frame” of the comment and its content.I have pushed a fix to the repo