1

I've recently started playing around with ncurses. As far as I understand, C doesn't support passing by reference.

However, there are some functions that seem to exhibit such a behavior:

calling getmaxyx(stdscr, maxRow, maxCol); assigns the the number of rows and number of columns to maxRow and maxCol respectively. getyx seems to exhibit a similar behavior.

How is this done?

math4tots
  • 8,540
  • 14
  • 58
  • 95
  • 1
    I Also fell for this trick. It seemed so much a function that it never occured to me to think it to be a macro. I often perceived people using CAPITALS (like suggested in this answer [http://stackoverflow.com/questions/369495/what-are-the-valid-characters-for-macro-names/369534#369534]) to express macros,but it seems not be a rule, does it? – humanityANDpeace Mar 13 '13 at 19:21

1 Answers1

4

This is not a direct function call, but a macro, take a look here:

All of these interfaces are macros. A "&" is not necessary before the variables y and x.

For example:

#define getmaxyx(w, y, x)   (y) = getmaxy(w), (x) = getmaxx(w)
MByD
  • 135,866
  • 28
  • 264
  • 277