Jump to content
  • 0

Vitis2022.2 pointer error


K.K

Question

I tried the zmod sample program on vitis2022.2, but I got the following error. What is causing this? Also, how can I solve it?
error: ordered comparison of pointer with integer zero ('FlashEnv*' {aka '_flash_env*'} and 'int')

file:flash.c
program:
------------
FlashEnv *flash_env = (FlashEnv *)malloc(sizeof(FlashEnv));
if (flash_env < 0) {
return XST_FAILURE;
------------

Thank you.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I can't speak to the sample program specifically, but when malloc fails it usually returns NULL. So try 

if (flash_env == NULL) {

  return XST_FAILURE;

...

Note, you probably have to include stdio.h to get the definition of NULL. 

Disclaimer: It's been 40+ years since I regularly programmed in C.

Link to comment
Share on other sites

  • 0

Hi @K.K

Apologies for the delayed response.

The error isn't at runtime, so malloc actually returning NULL (which is usually defined as zero) at runtime is not necessarily what's happening here, but "if flash_env == NULL" is still good advice. Possibly compiler settings were modified between versions to be harsher on something which worked before, which might mean that either a NULL check or an explicit cast of the pointer to an unsigned integer could also help.

As a note, Digilent hasn't tested the Zmod library sources in 2022.1 (edit: or 2022.2).

Thanks,

Arthur

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...