0 out of 1 rated this helpful - Rate this topic

Compiler Error C2006

'directive' expected a filename, found 'token'

Directives such as #include or #import require a filename. To resolve the error, make sure token is a valid filename. Also, put the filename in double quotes or angle brackets.

The following sample generates C2006:

// C2006.cpp
#include stdio.h   // C2006

Possible resolution:

// C2006b.cpp
// compile with: /c
#include <stdio.h>
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Compiler Error C2006
I use this line: #import rename "C:\Program Files (x86)\Microsoft Office\Office\EXCEL9.OLB" no_namespace
in my VC++ 2010 code . when i compile i get these:
1>------ Build started: Project: AutoProject, Configuration: Debug Win32 ------
1>Build started 11/02/2012 10:56:36.
1>InitializeBuildStatus:
1>  Touching "Debug\AutoProject.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>cl : Command line warning D9035: option 'clr:oldsyntax' has been deprecated and will be removed in a future release
1>  AutoProjectDlg.cpp
1>c:\users\bo\documents\visual studio 2010\projects\autoproject\autoproject\CApplication.h(3): error C2006: '#import' : expected a filename, found 'identifier'
1>c:\users\bo\documents\visual studio 2010\projects\autoproject\autoproject\CApplication.h(3): fatal error C1083: Cannot open type library file: '': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.83
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

but the path exists and the file also.
could everyone tell me where the mistakes are?
thanks,

Advertisement