-3

I want to use debugging quality of microsoft visual studio and its built in compiler does not allow me to declare array like int a[n] giving errors like it should be constant value and thus my time is being wasted on dynamically allocating it. Also I am unable to include libraries like bits/stdc++.h

I am using windows 10. Please tell me how can I configure my compiler.For my purpose I will be having just one cpp file.

My main purpose will be to solve questions from spoj,codeforces etc

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Ankit Jain
  • 3
  • 1
  • 2
  • 9
    "*its built in compiler does not allow me to declare array like int a[n] giving errors like it should be constant value*" C++ doesn't let you do that. It's a C feature that GCC ports into C++. – Nicol Bolas Mar 26 '17 at 17:34
  • 3
    Are you seriously complaining that VC++ does not allow you to use a **non-standard** feature you shouldn't be using in the first place? – Remy Lebeau Mar 26 '17 at 17:35
  • 5
    Not be a jerk, but it probably took you more time to submit the question then to simply type `std::vector a; a.resize(n);` – linuxuser27 Mar 26 '17 at 17:37
  • 2
    @linuxuser27 why not `std::vector buf(n);`?! – JHBonarius Mar 26 '17 at 17:38
  • The visual-studio-2012 and visual-c++-2010 tags are unnecessary. You are talking about how to implement a compiler in Visual Studio 2017. You should get rid of those tags and replace them with visual-studio-2017. Tags need to refer to the question at hand. – NathanielSantley Mar 26 '17 at 17:38
  • @J.H.Bonarius Duh :) – linuxuser27 Mar 26 '17 at 17:39
  • 3
    `bits/stdc++.h` is not a "library" but an **internal** GCC header file whose name or path should never appear in your own code. Including it is a terrible practice which I think has appeared about one year ago and which just isn't going away anymore. I wonder where people are picking it up. – Christian Hackl Mar 26 '17 at 17:42
  • @linuxuser27 I know that but ehat if I want to use gcc compiler in visual studio ? How can I configure that? – Ankit Jain Mar 26 '17 at 18:02
  • 1
    Don't write code with VLAs, please. Just stick to standard C++. – Jesper Juhl Mar 26 '17 at 18:38
  • 1
    @AnkitJain Making Visual Studio use another C/C++ compiler is a non-trivial process. I seem to recall there being a way to use MinGW in VS, but I can't really recall specifics. If you are looking to practice and solve online questions I second JesperJuhl advice and use standard C++ so you can learn the language which should be compiler agnostic. – linuxuser27 Mar 26 '17 at 21:51
  • Possible duplicate of [How to use GCC with Microsoft Visual Studio?](http://stackoverflow.com/questions/14768073/how-to-use-gcc-with-microsoft-visual-studio) – Lord_Curdin Mar 31 '17 at 07:00

1 Answers1

1

There are three different options.

  1. Create a Custom Build Tool
  2. Makefile Project
  3. Cross-Platform Development

Theres a similar question with a good answer with the explanation of my Options How to use GCC with Microsoft Visual Studio?

Community
  • 1
  • 1
Lord_Curdin
  • 957
  • 1
  • 14
  • 27