Compiler Error C2341
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Error C2341

Error Message

'section name' : segment must be defined using #pragma data_seg, code_seg or section prior to use

An allocate statement refers to a segment not yet defined by code_seg, data_seg, or section pragmas.

The following sample generates C2341:

// C2341.cpp
// compile with: /c
__declspec(allocate(".test"))   // C2341
int j = 1;

Possible resolution:

// C2341b.cpp
// compile with: /c
#pragma data_seg(".test")
__declspec(allocate(".test"))
int j = 1;
Show:
© 2016 Microsoft