2

Everywhere I read, people advise against using global variables. If the program consist of single cpp file, will using global variables still be a risk?

Will using global variables in C have the same hard-to-find bugs?

WhatIf
  • 653
  • 2
  • 8
  • 18
  • 1
    If the file is very large, yes. – Emil Laine Oct 13 '15 at 22:03
  • If you want to make very small apps, you can freely use global variables in some obvious cases. But not in all cases. And in the C language bugs are much more hard-to-find than in C++. – Mykola Oct 13 '15 at 22:04
  • 1
    I think that the risks and problems caused by global variables are not specific to a language. They are to avoid as much as possible in any language. – A.S.H Oct 13 '15 at 22:05
  • @zenith IMO the very large file is a risk itself. – xiaofeng.li Oct 13 '15 at 22:11

0 Answers0