Gregory Kuhn
Gregory Kuhn

Reputation: 1697

C code snippet dot operator syntax

I encountered the following code snippet within a cstartup file for a cortex m0 micro - cstartup_M.c

#pragma location = ".intvec"
__root const intvec_elem __vector_table[] =
{
  { .__ptr = __sfe( "CSTACK" ) },
  __iar_program_start,

  NonMaskableInt_Handler,
  HardFault_Handler,

Could someone please explain the syntax within the line: { .__ptr = __sfe( "CSTACK" ) },

Specifically:

  1. What is the purpose of the additional code block?
  2. What is going on here: .__ptr?

Upvotes: 1

Views: 136

Answers (1)

fuz
fuz

Reputation: 92994

That's the new C99 initialization syntax. An initializer of the form

.field = value

initializes structure member field to value instead of initializing the next structure member in order.

Upvotes: 3

Related Questions