LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   "undeclared" error when compiling enet (https://www.linuxquestions.org/questions/programming-9/undeclared-error-when-compiling-enet-4175642154/)

abk4523 11-11-2018 08:52 AM

"undeclared" error when compiling enet
 
I am following this tutorial:

https://www.linuxjournal.com/content...ogramming-enet

and running into an "error: ipeerCount undefined" error when compiling the sever program. The tutorial says the code snippet should send any messages to all clients other than the original client. I'm thinking of adding a routine to the "ENET_EVENT_TYPE_CONNECT:" event to count the number of clients and use it to control the while loop, but would it be the right way? I understand this solution would not skip the original sender, but that is not important at the moment.

astrogeek 11-11-2018 12:19 PM

You may receive more, better replies if you can frame your question inline and not require others to visit a third-party link simply to understand what you are asking. Asking others to read through an online tutorial simply to understand the question will turn away many who may otherwise be able to help.

You seem to be asking two questions, one about a compile error and another about modifying the application behavior. Please include the complete error message along with any relevant information about what you have done to identify the problem. For example, if the error complains about an undefined variable, have you tried to identify where it is, or should be defined?

For modifications to the existing code, it would be most helpful to others if you would reduce the code to a minimum example which shows how it currently works, and how you want to change it.

Please review the Site FAQ for guidance in posting your questions. Especially, read the link in that page, How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!

KenJackson 11-12-2018 10:22 AM

Quote:

Originally Posted by abk4523 (Post 5925035)
and running into an "error: ipeerCount undefined" error when compiling the sever program.

I searched that article (CTRL-F in Firefox), and only found "ipeerCount" on one line, in the server code:
Code:

for (i=0; ipeerCount; i++) {
That looks like a typo. It probably should be something like this, though there's no "peerCount" variable declared either:
Code:

for (i=0; i < peerCount; i++) {
Using the search box at http://enet.bespin.org/ reveals there is a peerCount field in struct (or class?) ENetHost, so it should probably be this:
Code:

for (i=0; i < server->peerCount; i++) {


All times are GMT -5. The time now is 08:22 AM.