Author Topic: Can you use namespace std with DFSDK Apps?  (Read 2162 times)

nednones

  • Guest
Can you use namespace std with DFSDK Apps?
« on: May 11, 2012, 02:27:42 pm »
Just tried using a using namespace std in one of my test apps and declared a string within one of my methods and the app seems to works. I thought this type of programming was not allowed?

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: Can you use namespace std with DFSDK Apps?
« Reply #1 on: May 11, 2012, 02:29:44 pm »
Anything that's standard C / C++ is fine to include.  What you can't use is anything Microsoft-specific or anything non-standard.
Tim Sommers
DragonFireSDK Team

martol1ni

  • Guest
Re: Can you use namespace std with DFSDK Apps?
« Reply #2 on: May 11, 2012, 02:47:11 pm »
It works within Visual C++, but when you build it, it will give you errors when you're building in in the Build Center, at least on
Code: [Select]
using namespace std;I think you can use
Code: [Select]
using std::string;
using std::vector;

And so on.. I think i remember that didn't give me any errors, and saving me from ALOT of writing :)

nednones

  • Guest
Re: Can you use namespace std with DFSDK Apps?
« Reply #3 on: May 12, 2012, 04:26:28 am »
This is precisely what I thought but the build server didn't throw any errors using namespace std and then consequently declaring a string variable within my code. However, saying that, the app does not seem to work properly but I'm not sure if it's becuase of this or something else?

martol1ni

  • Guest
Re: Can you use namespace std with DFSDK Apps?
« Reply #4 on: May 12, 2012, 06:46:29 am »
Then I'm afraid I don't know. I remember I was getting errors along with the build.zip when I was using
Code: [Select]
using namespace std;
Are the errors even connected to your string variables?

MetaHaze

  • Guest
Re: Can you use namespace std with DFSDK Apps?
« Reply #5 on: May 24, 2012, 10:55:28 pm »
I have been using: 

using namespace std;

without any errors from the build server or app where I do a lot of string, string array and char manipulation.

No issues with the following includes:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <cstring>
#include <string>
#include <vector>