Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable auto-inserted 'inline' keyword in Visual Studio?

I love the Move definition location refactoring feature of Visual Studio 2015 except one thing. It automatically insert inline keyword ahead of function definition. So I always had to remove them by my self.

It is like this.

Before refactoring.

class GameLoop
{
public:
    void drawGame() {

    }
};

After refactoring(Move definition location)

//GameLoop.h
class GameLoop
{
public:
    void drawGame();
};
//GameLoop.cpp
inline void GameLoop::drawGame() {

}

Anybody knows how to disable this auto inline keyword?

Thanks.


For whom doesn't know where is this feature.

  1. Move cursor on the method you want refactor

  2. [Edit]->[Refactor]->[Move Definition Location]

or

  1. Press Ctrl+. shortcut and select Move Definition Location
like image 513
JaeJun LEE Avatar asked Jan 18 '26 22:01

JaeJun LEE


1 Answers

According to https://learn.microsoft.com/en-us/cpp/ide/refactoring/move-definition-location?view=msvc-140 it seeems as if its function is to move from source to header file, not vice versa.

However, the inline keyword for non-template functions in the source file - as you describe - is semantically correct, since the function definition within the class definition is implicitly inline, but it is not really a desirable behavior. I agree. I guess you could post this as an improvement issue to the VS devs.

On a sidenote, what I observed for template functions was (in VS2019):

  1. Move function definition from within the class body to outside the class body in the header file.
  2. Move function definition back from outside the class body to inside.
  3. back and forth in header file.

This behavior has much more merit in my opinion.

like image 121
CasualCay Avatar answered Jan 21 '26 12:01

CasualCay