1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows11 の VSCode+Emscripten で wasm によるハローワールド (3)

Last updated at Posted at 2025-10-08

すべての記事

ブラウザで C++ のコードをステップ実行

前の記事 で作成したプロジェクトの一部を変更しソースマップ ファイルを作成することで、ブラウザの開発者ツールを使って C++ のソースコードをステップ実行することができる。

C:\wasm\project\02-helloworld-web\CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(02_helloworld_web LANGUAGES CXX)

add_executable(02_helloworld_web main.cpp)
target_link_options(02_helloworld_web PRIVATE
    "-gsource-map"
    "-sASSERTIONS=1"
    "-sSAFE_HEAP=1"
)

追加した行は -gsource-map のみ。
この状態でプロジェクトをクリーン・ビルドする。

image.png

build ディレクトリにソースマップが作成されていることを確認。

C:\wasm>dir C:\wasm\project\02-helloworld-web\build\*.map
 ドライブ C のボリューム ラベルは OS です
 ボリューム シリアル番号は E886-5372 です

 C:\wasm\project\02-helloworld-web\build のディレクトリ

2025/10/08  22:14            13,105 02_helloworld_web.wasm.map
               1 個のファイル              13,105 バイト
               0 個のディレクトリ  626,459,348,992 バイトの空き領域

この状態でブラウザの開発者ツールを開くと C++ のソースコードがステップ実行できる。

image.png

printf() で出力したものはコンソールに出力されている。

image.png

は JavaScript から C++ の関数を呼び出してみる。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?