Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Some beginner C++ questions.


  • Please log in to reply

#31
Fealos

Fealos

    Member

  • Topic Starter
  • Member
  • PipPip
  • 17 posts
I got an email back from the guy who created aaio.h, I asked if it was possible to use on a mac. Here is his response:

The answer is both yes and no. Assuming you are building a C++ tool in XCode you can include aaio in your project by adding the aaio.h and aaio2.c file to your project and change #include <termio.h> to #include <sys/ioctl.h> in aaio2.c. This should make your code compile. However the "terminal" in which XCode runs its C++ tool targets whe you run the project from within XCode is not a compliant terminal and it is therefor not possible to change the mode of the "terminal".

To solve that you must build your project in XCode but run it from a Terminal.app session (or an xterm if you use X11). You can locate your binary in /PATH_TO_YOUR_PROJECT/build/NAME_OF_EXECUTABLE.

Hope this helps


so, I changed the header call in aaio2.c, but he mentions adding aaio2.c to my project. Does this mean just moving it to that directory, or do I have to actually call it in my code? After just changing that line in aaio2.c I get the same conclusion I did before.

getting close, I think.
  • 0

Advertisements


#32
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 876 posts
yes - add aaio2.c to the project.

here's why it would compile without aaio2.c:
the header file(.h) has the declaration for kbhit() and getch(). the project will compile as long as the .h file has the proper syntax. when you run it, however, the code for kbhit() and getch() in aaio2.c was never compiled(not part of the project) causing a runtime error.

add aaio2.c to the project and compile.
  • 0

#33
Fealos

Fealos

    Member

  • Topic Starter
  • Member
  • PipPip
  • 17 posts
I didn't know how to add a .c file to my code, so I just tried #include "aaio2.c" just under my header includes. Everything seems to be working!

So, why do I have to call the .c file and the header file? Can the compiler not see that those functions are defined in aaio2.c? Also, why not code out everything in the .h file? What's the point of keeping the files separate? I'm glad I got everything working. Not without lots of help, though. Thanks again!
  • 0

#34
Fealos

Fealos

    Member

  • Topic Starter
  • Member
  • PipPip
  • 17 posts
Ohhhhhhh yeah, it works. He was even wrong about the version of terminal that Xcode uses not being able to run it. It works fine in that terminal, as well as the system terminal. The functions work just as they should, too. ;) :tazz:
  • 0

#35
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 876 posts
congrats!
great idea - emailing the author

to clarify - 'add to the project' is referring to a project created using visual c++ or borland. the project contains a list of files selected by the user which it looks for when compiling. if you are not using a project, simply adding the source code aaio2.c to the folder with the other files will suffice(if using '*.c *' in the command line compile statement).

if aaio2.c is part of a project, the include statement for it can be removed.

hopefully your classwork will be much easier than this has been. c++ can be aggravating - just be patient and don't let it get to you.

great work - nice job finishing the task
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP