简体   繁体   中英

can anyone explain how the “->” is implemented in the #define

I'm working on a reference design with this line as a #define

#define MEDIA_EXT_STATE "\"adv7611 12-004c\":1 -> \"40080000.tpg\":0[%d]"

The sprintf function uses it which is then passed to the media_parse_setup_links() function.

sprintf(media_formats, MEDIA_EXT_STATE, 1);
ret = media_parse_setup_links(media, media_formats);

The macro defines MEDIA_EXT_STATE as a string literal, similar as

#define FOOBAR "foo -> bar"

defines FOOBAR as the string literal "foo -> bar" . Maybe you got confused by the escaped " , but thats just like with ordinary string literals:

std::cout << "\"123";

prints "123 .

To know what is the meaning of the -> in the string, you'd have to look into the implementation of media_parse_setup_links or read the documentation.

It simply translates to:

 sprintf(media_formats, "\"adv7611 12-004c\":1 -> \"40080000.tpg\":0[%d]", 1);

There is no pointer operation, as it is just part of the string.

When removing the quotes it becomes more obvious:

 sprintf(media_formats, "'adv7611 12-004c':1 -> '40080000.tpg':0[%d]", 1);

can anyone explain how the “->” is implemented

It's just text. It is "implemented" the same way as this:

std::string example = "->";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM