# Need some help to get VS Code to debug CPP and haxe-eval

**URL:** <https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363>\
**Category:** Haxe\
**Tags:** ide, vscode\
**Created:** [April 15, 2020, 11:31am UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363 "2020-04-15T11:31:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyliathy](https://community.haxe.org/user_avatar/community.haxe.org/kyliathy/32/452_2.png) [@Kyliathy](https://community.haxe.org/u/Kyliathy)\
**Post date:** [April 15, 2020, 11:31am UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/1 "2020-04-15T11:31:37Z")

</div>

Hello 🙂. I can’t get any sort of debugging going in VS Code.

You can see everything (`build hxml`, `.vscode/launch.json` and `.vscode/tasks.json`) in this repo:

> **[Kyliathy/haxe-vcode-cpapi](https://github.com/Kyliathy/haxe-vcode-cpapi/tree/master/project)**
>
> master/project

This is part of an ongoing open source project where I aim to demonstrate to people how Haxe can be used for Cross Platform APIs. I want to cover a very wide range of uses, including 3D engines, plugins, modding and more. I intend to demonstrate lots of language features too. And to make it all debuggable and deployable to as many targets and configs as possible. But… I’m stuck 🙂

More details about why I’m doing this:

I’m working on something that will hopefully be better than the “Getting started with Haxe” series of articles. It’s somewhat opinionated in that I use Visual Studio Code.

However, what I intend to do is worth the ‘opinion’. Since I’ve chosen an IDE, users will get FULLY functional Haxe boilerplates for various types of projects, using various libraries. I plan to gather everything in one repo.

But for now, I’m focused on cross-platform API projects, which is one of the strengths of Haxe.

The repo is here:

> **[Kyliathy/haxe-vcode-cpapi](https://github.com/Kyliathy/haxe-vcode-cpapi)**
>
> Visual Studio Code project for a Haxe Cross Platform API Project that touches multiple targets.

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [April 15, 2020, 11:38am UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/2 "2020-04-15T11:38:40Z")

</div>

Have a look at this repo - it has working launch configs for every Haxe target that can be debugged (JS, C++, HL, Eval, Flash).

> **[Gama11/HaxeRepro](https://github.com/Gama11/HaxeRepro)**
>
> Contribute to Gama11/HaxeRepro development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Kyliathy](https://community.haxe.org/user_avatar/community.haxe.org/kyliathy/32/452_2.png) [@Kyliathy](https://community.haxe.org/u/Kyliathy)\
**Post date:** [April 15, 2020, 9:14pm UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/3 "2020-04-15T21:14:23Z")

</div>

Oooh! Sweet! 🙂 . Tasty configs for me to understand! Thank you! This is what I call “investigation progress” 😃

I cloned it, but I’m unable to debug CPP:

“Debug server connected!”

But the breakpoint I put in the code is not triggered. Or am I missing something?

I didn’t try the other targets yet. Too tired now. Must sleep.

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [April 16, 2020, 12:31pm UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/4 "2020-04-16T12:31:24Z")

</div>

Not sure, seems to work for me:

 ![](https://community.haxe.org/uploads/default/original/2X/8/8e709c09d4b65ca9cb8d46043cfffac6c4bff95a.png)

Are you on Windows?

---

<div class="post-metadata">

**Author:** ![Kyliathy](https://community.haxe.org/user_avatar/community.haxe.org/kyliathy/32/452_2.png) [@Kyliathy](https://community.haxe.org/u/Kyliathy)\
**Post date:** [April 16, 2020, 6:31pm UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/5 "2020-04-16T18:31:10Z")

</div>

Hi Jens, thanks for answering again 🙂 . Yes, Windows 10.

Actually, breakpoints work, but not correctly. I made the blasphemy of modifying the code a bit before running 😃 , which is why it didn’t work:

```haxe
	static function main() {
		var a:Int = 2;
		var b:Int = 4;
		var ab:Int;
		ab = a + b;
		Sys.println("The sum of a and b is: " + ab);
		Sys.stdin().readLine();
	}

```

Put a breakpoint on ab = a + b 🙂 It doesn’t hit for me. It does hit BOTH the `println` and the `b: Int = 4` assignment, but not the line with addition. Actually, it steps over it when I step. Just to be clear, the assignment DOES happen, it just doesn’t hit the breakpoint.

Bonus question: why isn’t my `Sys.stdin().readLine();` working? I can’t get the program to stop no matter how many times I hit Enter in the debug console. No line seems to be read.

---

<div class="post-metadata">

**Author:** ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)\
**Post date:** [April 16, 2020, 6:55pm UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/6 "2020-04-16T18:55:38Z")

</div>

It looks like that line gets optimized away. It gets merged into the declaration as you can see in the AST dump (`dump\cpp\Main.dump`) on the right here:

 ![](https://community.haxe.org/uploads/default/original/2X/d/d17c24cc8e8f80a30ecee9f1bc7c860d449ffb8b.png)

Seems better with `-D analyzer-no-fusion`, but then you also have this ugly `_hx_tmp`:

![](https://community.haxe.org/uploads/default/original/2X/9/928196d5b3dc3910d63b48f65d060af365fa2000.png)

Regarding `readLine()` not working, I think the VSCode debug console may not accept input? There may be some setting to use the Terminal instead, I don’t quite remember.

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [July 20, 2022, 10:37pm UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/7 "2022-07-20T22:37:19Z")

</div>

Hej !

I just discovered the VSHaxe debugger but I can’t get it working. (2 years later I wake up 🤣 )  
It tells me that it miss server.hxml configuration in lauch.json (server.hxml is my current build for PHP target…)  
First, I even don’t know if I can use it for example in a large project for PHP plateform (so with my server.hxml build file - I just want to debug some macros), or I must create a smaller projet with --interp “output” ?

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [July 21, 2022, 7:51am UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/8 "2022-07-21T07:51:51Z")

</div>

Sorry, I’m really a noob with VSCode, I had to put launch.json into the .vscode directory, it works fine now.  
BTW it seems to be an amazing tool for debugging macros !  
Thanks a lot for your work !

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [July 21, 2022, 10:38am UTC](https://community.haxe.org/t/need-some-help-to-get-vs-code-to-debug-cpp-and-haxe-eval/2363/9 "2022-07-21T10:38:01Z")

</div>

Hej @Gama11,

I took the files (settings and task) from your repository and pasted them into the global .config/Code/User dir and now when trying to compile, compilation runs fine but I get this error for task :

```haxe
Error: The haxe task detection didn't contribute a task for the following configuration:
{
    "type": "haxe",
    "args": "active configuration",
    "group": {
        "kind": "build",
        "isDefault": true
    }
}
The task will be ignored.

```

I don’t get this error when the settings and task are in my project .vscode dir.  
How to solve that please ? (I’m on the last VSCode version (1.69.2) and last VSHaxe extension version (2.24.0)
