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

No type named 'VarDictionary' in namespace 'pp' using PNaCl

本文关键字:类型 pp 使用 PNaCl VarDictionary 命名空间      更新时间:2023-10-16

有人能告诉我为什么我得到编译错误

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

我想在函数

中设置一个字典
virtual void HandleMessage(const pp::Var& message) {
}

我从这个Google页面的底部复制了这个例子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添加头文件,这是您试图访问的类声明的地方。

该头文件的源代码在这里