I'm developing some additional options for a game (which means I don't have knowledge about whole game's methods, classes etc.).

Anyway, I have been trying to build the project for codes I've developed to test them. I've encountered some DirectX, Windows SDK Version, Compiler problems but managed to solve them. But now I'm encountering some BitScanReverse error.

It says: C3861 '_BitScanReverse': identifier not found

Here is whole code for the error I'm encountering:

#pragma once

#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include <initializer_list>
#include <functional>
#include <iterator>   

    #ifdef _MSC_VER // BitScanReverse ERROR 1
        _BitScanReverse(&n, ~code);
        n = sizeof(long) * 8 - 1 - __builtin_clzl(~code);

    code &= ~(-1 << n);
    n = 6 - n;

    #ifdef _MSC_VER // BitScanReverse ERROR 2
        _BitScanReverse(&n, ucode);
        n = sizeof(long) * 8 - 1 - __builtin_clzl(ucode);

I've downladed source codes through SVN, so whole project is actually working. I just couldn't manage to build it in my local laptop or desktop computer.

By the way, I've tried to build it with Visual Studio 2015 Enterprise (with other errors), Visual Studio 2017 Proffesional and Community Edition (with same errors). And actually this project was developed with Visual Studio 2013 and 2015.

I'm not even good C++ coder so I couldn't figured out the problem. Does anyone have an idea?


1 Answer 1


According to the docs here _BitScanReverse is in the header file <intrin.h>. Try adding #include <intrin.h> to your file.

  • \$\begingroup\$ Thank you it worked. But now I'm trying to solve an error with xmemory file. Thank you anyways. \$\endgroup\$
    – Gunes K
    Jul 4, 2017 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .