Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: ‘str2int’ undeclared (first use in this function) #1888

Open
grenaud opened this issue Feb 14, 2025 · 3 comments
Open

error: ‘str2int’ undeclared (first use in this function) #1888

grenaud opened this issue Feb 14, 2025 · 3 comments

Comments

@grenaud
Copy link

grenaud commented Feb 14, 2025

I am getting the following error while building htslib:


      |         ^~~~~~~~
test/test_khash.c:53:18: error: ‘str2int’ undeclared (first use in this function)
   53 |     if (kh_stats(str2int, h, &empty, &deleted, &hist_size, &hist) == 0) {
      |                  ^~

But the rest seems to build.

@whitwham
Copy link
Contributor

Could we have some more details? Like the compiler you are using, the version of htslib and the operating system?

@grenaud
Copy link
Author

grenaud commented Feb 17, 2025

sure! It was a git clone done 3 days ago, c++ is c++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Linux 6.8.0-51-generic
Ubuntu 24.04.1

@jkbonfield
Copy link
Contributor

This looks like a missing khash init macro, possibly caused by forgetting to include htslib/kash_str2int.h. str2int here isn't a variable or a type, but a preprocessor token which is appended to the various khash functions.

#include "khash.h"

KHASH_MAP_INIT_STR(str2int, int)

/*
 *  Wrappers for khash dictionaries used by mpileup.
 */

static inline void *khash_str2int_init(void)
{
    return kh_init(str2int);
}
...

The KHASH_MAP_INIT_STR creates functions like kh_init_str2int which is what the kh_init(str2int) expands to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants