Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to re-enable `uint` type in g++ 4.7+?

Tags:

c++

gcc

I have a mass of code that I'm trying to convert from g++ version 4.2.2 to 4.7.2. In version 4.2.2 and prior, it seems that uint was defined as unsigned int. I know this is not a standard c++ thing and that real men write ISO standard C++, but I was wondering if there was a flag or some sort of way to make g++ accept uint without modifying all the source files. Can I change CPPFLAGS or add a switch to the g++ runline? My googles yielded nothing. I have some source files coming from a different group at work and I'd like to accept their uint transgressions.

e.g.

#include <iostream>
#include <fstream>
#include <assert.h>
using namespace std;
int main(void) {
    uint foo = 0xdeadbeef;
    cout<<hex<<foo<<endl;
}

yields:

/tmp/rbroger1/gcc_update rbroger1 @ plxc25804 
% /usr/intel/pkgs/gcc/4.2.2/bin/g++ ~/tmp.cc && ./a.out
deadbeef
/tmp/rbroger1/gcc_update rbroger1 @ plxc25804
% /usr/intel/pkgs/gcc/4.7.2/bin/g++ ~/tmp.cc && ./a.out
/nfs/pdx/home/rbroger1/tmp.cc: In function 'int main()':
/nfs/pdx/home/rbroger1/tmp.cc:8:5: error: 'uint' was not declared in this scope
/nfs/pdx/home/rbroger1/tmp.cc:8:10: error: expected ';' before 'foo'
/nfs/pdx/home/rbroger1/tmp.cc:9:16: error: 'foo' was not declared in this scope
like image 668
Ross Rogers Avatar asked Jan 14 '23 04:01

Ross Rogers


1 Answers

You can add a -include a_file_where_there_is_typedef_to_uint.h flag to g++

From the manual

-include file

Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.

If multiple -include options are given, the files are included in the order they appear on the command line.

like image 60
Industrial-antidepressant Avatar answered Jan 23 '23 23:01

Industrial-antidepressant