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

C functions should return int or void #119

Open
paskino opened this issue Apr 15, 2019 · 3 comments
Open

C functions should return int or void #119

paskino opened this issue Apr 15, 2019 · 3 comments

Comments

@paskino
Copy link
Contributor

paskino commented Apr 15, 2019

int would be better so that basic checks could be implemented

@dkazanc
Copy link
Collaborator

dkazanc commented Jun 2, 2019

@paskino not sure what you mean exactly? C functions currently return either zero or a pointer to an array. What do you mean by int?

@paskino
Copy link
Contributor Author

paskino commented Jun 3, 2019

It's a good practice to return ints on C functions so that one can check the return value and decide if it run correctly: i.e. if return is 0 then OK, otherwise some problem.

int function(int a, float* b){

   ... 
  if (something goes wrong)
  return 1;
  ...
  if (something else goes wrong)
  return 2;

return 0;
}

If you want to return an array it'd be better to have it passed in the arguments.

@dkazanc
Copy link
Collaborator

dkazanc commented Jun 3, 2019

ok it makes sense. Will try to incorporate.

paskino pushed a commit that referenced this issue Jan 22, 2021
- fixes #119
- related to #158
- TODO: work-around to avoid ignoring stats on PRs?
- partially reverts 894010d
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