1

I'm trying to rebuild an old VC++ project in VS 2010. Its currently spitting out an Invalid template argument error.

Do I have to add a .template keyword? Where?

The full error is below:

Error C2975: 'N' : invalid template argument for ToChunkFunc, expected compile-time constant expression

Community
  • 1
  • 1
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
  • Can you [fill in this semi compilable example of your code so it reproduces your error?](http://liveworkspace.org/code/3yahBj$8) – Tony The Lion Mar 20 '13 at 11:00
  • 2
    I have a feeling it's because `__LINE__` may not be considered a compile time constant. – Tony The Lion Mar 20 '13 at 11:04
  • Yes, when I click it and press F4 (goto definition), VS says `"cannot locate definition for __LINE__"`. I think this lib was built with VC9, and expects `__FILE__` and `__LINE__` to already exist as preprocessor keywords or whatever.... What does it usually stand for? – Robin Rodricks Mar 20 '13 at 11:06
  • 2
    Look at this - http://stackoverflow.com/questions/5397782/using-line-macro-as-a-template-parameter-in-visual-studio – borisbn Mar 20 '13 at 11:08
  • 2
    @Geotarget `__LINE__` is a macro that expands to be the current line number in the `__FILE__` which expands to be a filename. – Tony The Lion Mar 20 '13 at 11:09
  • 2
    @TonyTheLion: `__LINE__` _is_ a compile time constant because as a predefined macro it is replaced at preprocessing time, i.e. before "real" compilation even happens. – Sebastian Mach Mar 20 '13 at 11:52

1 Answers1

3

Error C2975 can be caused when the __LINE__ keyword is unavailable. If edit and continue is turned on, the compiler is run with the /ZI option which enables creation of a program database rather than a PDB file, in this mode the __LINE__ constant is unavailable because the line numbers can change at runtime. You'll need to use the /Zi command line option which has support for the __LINE__ constant.

To set this compiler option in the VS IDE:

  1. Open Project Settings > C/C++ > General.
  2. Modify the Debug Information Format property.
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607