C language backslash - Page 1
Forum section: electronics / projects

author: Jester
author_rank: Frequent Contributor
timestamp: March 23, 2022, 01:34:47 pm
content: Can someone tell me the significance of the backslash at the end of the first line in this define in a c language header file?The preceding comment is also confusing, I'm not sure what they are trying to convey with the \b//*****************************************************************************//// Macro to call SysCtl_delay() to achieve a delay in microseconds. The macro// will convert the desired delay in microseconds to the count value expected// by the function. \b x is the number of microseconds to delay.////*****************************************************************************#define DEVICE_DELAY_US(x) SysCtl_delay(((((long double)(x)) / (1000000.0L / \(long double)DEVICE_SYSCLK_FREQ)) - 9.0L) / 5.0L)

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: March 23, 2022, 01:42:39 pm
content: It's called an escape sequence and it is masking the newline from the compiler so that the two lines appear as one line to the compiler and it's used to provide a bit of readability to the coder instead of one gigantic long line of code.

author: mon2
author_rank: Frequent Contributor
timestamp: March 23, 2022, 01:42:47 pm
content: The details should be available on all C language websites but..It means that this line is continued onto the next. That is, treat the line that follows and this line as a single line of code.

author: Jester
author_rank: Frequent Contributor
timestamp: March 23, 2022, 02:06:30 pm
content: Quote from: Ed.Kloonk on March 23, 2022, 01:42:39 pmThanks, your explanation is better than the google hits I read.What do you make of the \b in the preceding comment?

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 23, 2022, 02:07:15 pm
content: It means it should countinue parsing the next line like if it was the current one.Ex.Code:if ((a==0x1234) && (b==0xAA55) && (c==1 || d!=0)){}Code:if ( (a==0x1234) && \(b==0xAA55) && \(c==1 || d!=0) ){}

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: March 23, 2022, 02:17:09 pm
content: Quote from: Jester on March 23, 2022, 02:06:30 pmDon't know.Mon2 explained it with less words. Ironic that my reply needed to be chopped up itself.You see a lot of the \ in bash scripts. You often need to break up unwieldy bash one-liners otherwise no hacker could ever understand the code.

author: PaulAm
author_rank: Frequent Contributor
timestamp: March 23, 2022, 02:18:40 pm
content: It is not needed in regular C statements. It's used in the original example because it is in a #define statement and macros are defined in a single line. The backslashes are used in that case to make it more readable

author: retiredfeline
author_rank: Frequent Contributor
timestamp: March 23, 2022, 02:22:36 pm
content: The \b is in a comment so doesn't affect the C code. My guess is it's a directive to a program that extracts documentation from block comments before functions, and \b might mean bold the next word or something like that.

author: RoGeorge
author_rank: Super Contributor
timestamp: March 23, 2022, 02:35:07 pm
content: Doxygen is a software tool to automatically build documentation by using the comment lines found inside the source files."\b" in Doxygen is to print the next word with bold font in the doc pageshttps://www.doxygen.nl/manual/commands.html#cmdb

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: March 23, 2022, 02:41:33 pm
content: Ah.