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

'f' not found in any directly #included header #101

Closed
Prime541 opened this issue Jan 20, 2017 · 2 comments
Closed

'f' not found in any directly #included header #101

Prime541 opened this issue Jan 20, 2017 · 2 comments

Comments

@Prime541
Copy link

Hello, cppclean gives me an error on a very simple example.
'f' not found in any directly #included header
What is wrong?
Best regards
Here is how to reproduce.

~>pip install --user --upgrade cppclean
~>source /mysoft/Python-3.4.3/setenv
~>PYTHONPATH=$PYTHONPATH:~/.local/lib/python2.6/site-packages
~>cat >| main.cpp << EOF
//#include <iostream>

void g(int j) {
  if (j == 3) {
    g(j+1);
  }
}

int f(const int& i) {
  g(i);
  return i - 1;
}

int main() {
  return f(1);
}

EOF
~>g++ ./main.cpp -o main && ./main ; echo $?
0
~>python3 ~/.local/bin/cppclean ./main.cpp ; echo $?
./main.cpp:3: 'g' not found in any directly #included header
./main.cpp:9: 'f' not found in any directly #included header
1
@myint
Copy link
Owner

myint commented Jan 20, 2017

I think g() and f() could be made static.

@Prime541
Copy link
Author

Prime541 commented Jan 23, 2017

You're right! C functions can be made private to a compilation unit (.c, .cpp) when prefixed with the 'static' keyword. Now cppclean won't complain that my static functions cannot be found in any header.

~>cat main.h
void g(int j);
~>cat main.cpp
//#include <iostream>
#include "main.h"

void g(int j) {
  if (j == 3) {
    g(j+1);
  }
}

static int f(const int& i) {
  g(i);
  return i - 1;
}

int main() {
  return f(1);
}

~>python3 ~/.local/bin/cppclean ./main.cpp ; echo $?
0

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

2 participants