Is it because my P4 version too old?

I encountered the following error when compiling my P4 program:

main.p4(214): [--Werror=type-error] error: Field miss is not a member of structure struct local_route
            if (local_route.apply().miss){
Compilation Error`Preformatted text`

My code is as follows:

            if (local_route.apply().miss){

Is it because my p4 version too old?

p4test --version
Version 1.1.0-rc1 (SHA: 8742052)

How do I upgrade the p4 version without affecting the execution of the p4run command?

Hello Duang,

First of all, you really have an extremely old version of the compiler. .miss attribute was added in the P4 language specification v. 1.2.0 in October 2019 and the current version is 1.2.3 (July 2022).

You should download the new version of the compiler from GitHub - p4lang/p4c: P4_16 reference compiler and build it using the instructions, provided there.

Alternatively, simply replace your code with the equivalent:

            if (!local_route.apply().hit){

But staying on latest version of the tools is the right thing to do nevertheless (assuming that you want to receive meaningful help and support in the future).

Happy hacking,

One way to get an Ubuntu 20.04 Desktop Linux VM that can be run on a macOS or Windows or Linux host system using free and open source VirtualBox is to download it from this page: p4-guide/ at master · jafingerhut/p4-guide · GitHub

That page also explains how to run a bash script that on a freshly installed Ubuntu 18.04, 20.04, or 22.04 Linux system, that will download and compile p4c and several other open source P4 development tools.

Neither of those options includes a command called p4run that I am aware of. I am not familiar with it. Thus if you followed either of the options above, you would need to figure out where you got p4run from and install it on the new system created by the steps above.

Thank you for your answer, p4run is a command in p4-utils. P4-Utils is an extension to Mininet that makes P4 networks easier to build, run and debug. P4-utils is strongly inspired by p4app.And here is the link to this tool

Hello Vladimir,
Thanks a lot for your answer, it is very useful for me.