Why are BlueprintPure and const incompatible?

Edit: as of 2019 you can now mark functions as BlueprintPure=false to get an execution pin onto function call nodes for functions that are marked as const in c++:

UFUNCTION(BlueprintCallabe, BlueprintPure=false)
int32 Foo() const;

Original answer:

UFunctions marked as const are always treated as BlueprintPure, so marking a function as const and BlueprintPure is redundant, and that’s why UHT complains. There are a couple things that are debatable about this:

  1. Conflating BlueprintPure and C++'s const keyword is a little dubious because C++ const does not imply purity. const functions may modify mutable members and global state.
  2. This error could just be a warning, because it is not fatal, it is simply redundant.

Current best practice is to mark const functions as BlueprintCallable and be aware that they will be treated as BlueprintPure by the compiler.

3 Likes