May 24th, 2023

Don’t name your header file security.h either

A customer found that the GetUserNameExW function suddenly disappeared.

error C2065: 'NameSamCompatible': undeclared identifier
error C3861: 'GetUserNameExW': identifier not found

What happened?

These symbols are defined in the header file secext.h in the Windows SDK, and that file was still present on the system and not corrupted. That file is usually not included directly, but rather gets pulled in indirectly when an application includes the header file security.h from the SDK.

Some more exploration revealed that another part of the project added a header file with the name security.h. This collides with the header file of the same name in the Windows SDK, so when the code did a

#include <security.h> // GetUserNameExW

expecting to get the header file from the Windows SDK, it instead picked up the project local version.

We learned some time ago that you shouldn’t name your DLL “security.dll”. And now we learned that the header file name security.h should also be avoided.

(In retrospect, the feature team should have chosen a less common name for their header file and DLL.)

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

4 comments

Discussion is closed. Login to edit/delete existing comments.

  • Sergey Misnik

    Same thing with Version.dll – had to rename to something like Revision.dll due to “kernel failed” like exceptions. Probably a good half of System32 directory libraries` names would cause problems.

  • Drew Cooper

    > In retrospect, the feature team should have chosen a less common name for their header file and DLL.

    I would bet that “security” was a less common name at the time.

  • Ruben Bartelink

    In general, I’d use `#include “security.h” in your example and/or bring it closer to the real scenario (where the double quotes means search including local paths; the angle brackets means “search only system include directories”)

    • 紅樓鍮 · Edited

      The angle brackets will instruct the compiler to search all include directories, which include the system include directories but also any directories specified with command line options such as . The double quotes instruct the compiler to first search the directory the file being compiled resides in, but then if not found, it will fall back to the include directories regardless.

      Most build systems provide options to specify "additional include directories" when compiling a target. It's very tempting to add the location of your own project's header files to that list. What it does is it adds that location to the...

      Read more