Why C++ code keeps breaking between sessions

So, this is a recurring problem I’m having while using a C++ project with blueprints and live coding in 5.3.2.

The C++ project contains only a Blueprint Functions Library, with some USTRUCTS and UFUNCTIONS. Those are linked on some blueprints on my project.

Problem is: I work as usual, build my C++ project with Ctrl+Alt+F11 in the Unreal Editor, edit my blueprints, but whenever I add a new function in the library and build again, save everything, shut down the editor and restart, all my blueprints dependent on this new code breaks. They say the variables dependent on the new structs and function calls are invalid, so it forces me to build again (Ctrl+Alt+F11) and go into every single node and hit “refresh node” on blueprints.

This happens almost every single time.

Am I doing anything wrong here?

Thanks.

That’s a really old bug that the devs still haven’t fixed.

Live coding doesn’t work at all if you change types. It’ll create a new type for the blueprints to continue working, but when you do a fresh rebuild in MSVC, those types become invalid and UE is supposed to clean it up, but it doesn’t work correctly if you did any changes in BP. The worst part is that if you modify a BP that uses a type that you changed, the BP is broken. If you try to fix it with the new type, it will break the next time you load the editor. And then it gets ever worse because those old types never die. They’ll remain in the editor even after you fix it and if you try to use live coding or change BP, it can completely break the editor and you have to delete the asset and start over.

I only use live coding for code changes only. If you add members or create or alter existing types, I close the editor and build in MSVC.

This feature of creating a new type so that the editor can keep functioning is called Object Reinstancing and I’ve never had it work correctly. It is buggy and the devs have never fixed it.

1 Like

Ok, now I understand why so many devs avoid C++ like a devil runs from the Cross. But anyway, for my project it is inevitable (and I guess for most serious projects it does too).

So, if I understood right, is it better to just disable Live Coding for good? What would be the best strategy then, just keep closing the editor before building code? That sounds terrible and a huge waste of time, especially on early stages where you change and refactor your code as hell until you get to a stable framework. No functional team can have any productivity with that, so I think there is a workaround strategy for this, right?

Or is it really trying to go C++ with Unreal will be always a living hell? :frowning:

Thanks again.

a) Turn off live coding
b) open your project in vs
c) Run visual studio proj. without debug enabled. (you can attach processes later on to UnrealEngine.exe)
d) Upon making changes in code build. Once finished unreal should give you a ready signal with an electronic beep.
e) if you add new c++ via the editor then go Tools =>Refresh Visual Studiu project (or you can right click your UProject file and regenerate there).
If VS is running it should prompt a refresh. If debugging is off then you can refresh all and it should be in sync with the editor with refreshed intellisense.

I ALWAYS run my project from vs (not by double clicking the uproject file), that way I’m certain all c++ files are up to date and intact for blueprints.

Haven’t had a missing parent or breaking code in years.

If you are getting compile errors in a fresh project, remember UE turns on live coding in every fresh project. You need to remember to disable it every time. (If there is a global flag to disable it forever I would check it instantly)

Okay, I’m gonna try that. If it solves, that will be a life saver.

Thanks for the tips anyway.

Bye :slight_smile:

Has nothing to do with C++. C++ is great. It’s Live coding that’s buggy.

First, make sure you’re not running in the debugger. Some people have had a little bit of success when not running in the debugger. I am not one of those people. :frowning:

Like I said earlier, you can use live coding for code changes (IOW, code inside your functions/methods). I’ve never had a problem with that. Any class or type not used by BP can also be modified. If you want to change/edit/add/remove a member or modify a type in any way and it’s used by BP, I shut down the editor, make my changes and then launch the editor again. Yes, it’s ridiculous.

For some reason, Epic doesn’t feel the need to fix this issue. It’s been like this for years.