# CMake C++17 "does not name a type" however class is included

**URL:** https://discourse.cmake.org/t/cmake-c-17-does-not-name-a-type-however-class-is-included/15637
**Category:** Usage
**Tags:** os:linux, tool:cmake
**Created:** [May 2, 2026, 6:52pm UTC](https://discourse.cmake.org/t/cmake-c-17-does-not-name-a-type-however-class-is-included/15637 "2026-05-02T18:52:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![matdubuisson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/matdubuisson/32/6112_2.png) [@matdubuisson](https://discourse.cmake.org/u/matdubuisson)
#### Post date: [May 2, 2026, 6:52pm UTC](https://discourse.cmake.org/t/cmake-c-17-does-not-name-a-type-however-class-is-included/15637/1 "2026-05-02T18:52:45Z")

</div>

Hello everyone,

I have upgraded a project from cmake 2.8 to cmake 4.0 and llvm 3.9.0 to 22.1.0 so of course I got compilation issues. For example in the project there is a class not found error for vm.hh file and the class is defined inside vm-decl.hh. vm.hh includes well vm-decl.hh but the error persists. I was wondering if it is a C++ or CMake error and if you have an idea to help to fix it ?

Thank you I really appreciate.

vm-decl.hh :

```auto
// Copyright © 2011, Université catholique de Louvain
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#ifndef MOZART_VM_DECL_H
#define MOZART_VM_DECL_H

#include <cstdlib>
#include <forward_list>
#include <atomic>

#include "core-forward-decl.hh"

#include "memmanager.hh"

#include "store-decl.hh"
#include "threadpool-decl.hh"
#include "gcollect-decl.hh"
#include "sclone-decl.hh"
#include "space-decl.hh"
#include "uuid-decl.hh"
#include "vmallocatedlist-decl.hh"

#include "atomtable.hh"
#include "bigintimplem-decl.hh"
#include "coreatoms-decl.hh"
#include "properties-decl.hh"

#include "debugger-decl.hh"

namespace mozart {

///////////////////
// BuiltinModule //
///////////////////

class BuiltinModule {
public:
  /**
   * @param vm The virtual machine
   * @param name The name of the built-in module to invoke
   */
  inline
  BuiltinModule(VM vm, const char* name);

  virtual ~BuiltinModule() {}

  /** Gets the name of the built-in module as an atom */
  atom_t getName() {
    return _name;
  }

  /**
   * Provides access to a built-in module
   * @returns The built-in module as a stable node
   */
  StableNode& getModule() {
    return *_module;
  }
protected:
  /**
   * Inits the built-in module into a protected node
   * @param vm The virtual machine
   * @param module A pointer on a node containing the module (generally unstable)
   */
  template <typename T>
  inline
  void initModule(VM vm, T&& module);
private:
  atom_t _name;
  ProtectedNode _module;
};

....

```

vm.hh :

```auto
// Copyright © 2011, Université catholique de Louvain
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#ifndef MOZART_VM_H
#define MOZART_VM_H

#ifndef MOZART_VM_DECL_H
  #error "vm-decl.hh should be defined before vm.hh"
#endif

#include "mozartcore.hh" // Includes mozartcore-decl.hh that includes vm-decl.hh
// #include "vm-decl.hh" // I tried to add that too but same behavior

#ifndef MOZART_GENERATOR

namespace mozart {

///////////////////
// BuiltinModule //
///////////////////

BuiltinModule::BuiltinModule(VM vm, const char* name)
  : _name(vm->getAtom(name)) {}

template <typename T>
void BuiltinModule::initModule(VM vm, T&& module) {
  _module = vm->protect(std::forward<T>(module));
}

....

```

When doing make :

```auto
[0%] Built target gensources
[0%] Building CXX object vm/vm/main/CMakeFiles/mozartvm.dir/emulate.cc.o
In file included from /home/matdubuisson/Desktop/mozart2/vm/vm/main/emulate.hh:29,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/debugger-decl.hh:29,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/vm-decl.hh:49,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/mozartcore-decl.hh:49,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/mozartcore.hh:28,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/mozart.hh:28,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/emulate.cc:25:
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh:43:1: error: ‘BuiltinModule’ does not name a type
   43 | BuiltinModule::BuiltinModule(VM vm, const char* name)
      | ^ ~~~~~~~~~~~~
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh:47:6: error: ‘BuiltinModule’ has not been declared
   47 | void BuiltinModule::initModule(VM vm, T&& module) {
      | ^ ~~~~~~~~~~~~
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh: In function ‘void mozart::initModule(VM, T&&)’:
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh:48:3: error: ‘_module’ was not declared in this scope; did you mean ‘module’? [-Wtemplate-body]
   48 | _module = vm->protect(std::forward<T>(module));
      | ^ ~~~~~~
      | module

....

```

Also the error from the #error has not been triggered.

The code comes from a multi-paradigm programing language that I improve for my thesis, this is my fork with the partial upgrade : [GitHub - matdubuisson/mozart2: Mozart Programming System v2 · GitHub](https://github.com/matdubuisson/mozart2) .

Thank you very much in advance,  
I hope to be clear else do not hesitate to ask for clarifications,  
Mattéo,

---

<div class="post-metadata">

### Author: ![matdubuisson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/matdubuisson/32/6112_2.png) [@matdubuisson](https://discourse.cmake.org/u/matdubuisson)
#### Post date: [May 3, 2026, 8:10am UTC](https://discourse.cmake.org/t/cmake-c-17-does-not-name-a-type-however-class-is-included/15637/2 "2026-05-03T08:10:45Z")

</div>

The problem still persists below for example, emulate.cc includes mozart.hh that includes mozartcore.hh that includes mozartcore-decl.hh that includes vm-decl.hh, then from mozart.hh vm.hh is included so normally vm-decl.hh is parsed before vm.hh but I do not know why the compiler does not see it :

```auto
matdubuisson@rogy:~/Desktop/mozart2/build$ make
[1%] Building CXX object vm/vm/main/CMakeFiles/mozartvm.dir/emulate.cc.o
In file included from /home/matdubuisson/Desktop/mozart2/vm/vm/main/emulate.hh:29,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/debugger-decl.hh:29,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/vm-decl.hh:49,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/mozartcore-decl.hh:49,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/mozartcore.hh:28,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/mozart.hh:28,
                 from /home/matdubuisson/Desktop/mozart2/vm/vm/main/emulate.cc:25:
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh:42:1: error: ‘BuiltinModule’ does not name a type
   42 | BuiltinModule::BuiltinModule(VM vm, const char* name)
      | ^ ~~~~~~~~~~~~
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh:46:6: error: ‘BuiltinModule’ has not been declared
   46 | void BuiltinModule::initModule(VM vm, T&& module) {
      | ^ ~~~~~~~~~~~~
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh: In function ‘void mozart::initModule(VM, T&&)’:
/home/matdubuisson/Desktop/mozart2/vm/vm/main/vm.hh:47:3: error: ‘_module’ was not declared in this scope; did you mean ‘module’? [-Wtemplate-body]
   47 | _module = vm->protect(std::forward<T>(module));
      | ^ ~~~~~~
      | module

```

---

<div class="post-metadata">

### Author: ![matdubuisson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/matdubuisson/32/6112_2.png) [@matdubuisson](https://discourse.cmake.org/u/matdubuisson)
#### Post date: [May 3, 2026, 8:18am UTC](https://discourse.cmake.org/t/cmake-c-17-does-not-name-a-type-however-class-is-included/15637/3 "2026-05-03T08:18:27Z")

</div>

Okay it was my fault I am still a beginner. I created accidentally a circular dependency that caused this error “does not name a type”. The problem emulate.hh included recusiverly mozartcode-decl.hh that includes debugger-decl.hh, however debugger-decl.hh included emulate.hh so recursively included itself.

It was the first time I hit a such error next time I will be more aware.
