c++ - 使用 PNaCl 的命名空间 'VarDictionary' 中没有名为 'pp' 的类型

标签 c++ google-nativeclient ppapi

谁能解释一下为什么会出现编译错误

error: no type named 'VarDictionary' in namespace 'pp'
        pp::VarDictionary dictionary;
        ~~~~^

我想在函数中设置字典

virtual void HandleMessage(const pp::Var& message) {
}

我从这个谷歌页面的底部复制了这个例子https://developer.chrome.com/native-client/devguide/coding/message-system

并尝试了像这样简单的事情

virtual void HandleMessage(const pp::Var& message) {
    pp::VarDictionary dictionary;
    pp::VarArray an_array;
    an_array.Set(0, pp::Var("string0"));
    an_array.Set(1, pp::Var("string1"));
    dictionary.Set(pp::Var("param_array"), an_array);
    PostMessage(dictionary);    
}

但是当我编译代码时,我得到了 pp::VarDictionary dictionary; 的错误消息,但是 pp::VarArray an_array; 没有问题

我正在使用来自 Google 的这个 Makefile

# Copyright (c) 2013 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

#
# GNU Make based build file.  For details on GNU Make see:
# http://www.gnu.org/software/make/manual/make.html
#

#
# Get pepper directory for toolchain and includes.
#
# If NACL_SDK_ROOT is not set, then assume it can be found three directories up.
#
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../..)

# Project Build flags
WARNINGS := -Wno-long-long -Wall -Wswitch-enum -pedantic -Werror
CXXFLAGS := -pthread -std=gnu++98 $(WARNINGS)

#
# Compute tool paths
#
GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
OSNAME := $(shell $(GETOS))
RM := $(OSHELPERS) rm

PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang++
PNACL_FINALIZE := $(PNACL_TC_PATH)/bin/pnacl-finalize
CXXFLAGS := -I$(NACL_SDK_ROOT)/include
LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lppapi_cpp -lppapi -ljsoncpp

#
# Disable DOS PATH warning when using Cygwin based tools Windows
#
CYGWIN ?= nodosfilewarning
export CYGWIN


# Declare the ALL target first, to make the 'all' target the default build
all: job1.pexe

clean:
    $(RM) job1.pexe job1.bc

job1.bc: job1.cc
    $(PNACL_CXX) -o $@ $< -O2 $(CXXFLAGS) $(LDFLAGS)

job1.pexe: job1.bc
    $(PNACL_FINALIZE) -o $@ $<


#
# Makefile target to run the SDK's simple HTTP server and serve this example.
#
HTTPD_PY := python $(NACL_SDK_ROOT)/tools/httpd.py

.PHONY: serve
serve: all
    $(HTTPD_PY) -C $(CURDIR)

最佳答案

您需要为 var_dictionary.h 添加头文件,这是声明您尝试访问的类的地方。

该 header 的源代码可用 here

关于c++ - 使用 PNaCl 的命名空间 'VarDictionary' 中没有名为 'pp' 的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39374003/

相关文章:

javascript - 如何实现向 NaCl(Chrome Native Client)发送消息后的回调?

将 chrome 原生客户端中的 pp::Var 数组转换为 C 整数数组

c++ - 如何在 NaCl 中为 ARM 提供不同的实现

javascript - 如何在Chrome浏览器和PNaCl插件之间正确传递JavaScript函数

python - 如何在 cython 模块中使用外部包装类?

c++ - wxWidgets 与 append 到 wxChoice 列表相反

javascript - 使用 Javascript 检测 Pepper (PPAPI) Flash

c++ - 用 C/C++ 编译 DLL,然后从另一个程序调用它

c++ - 如何在 0 个可变参数上专门化可变参数模板类?