• Welcome to Religious Forums, a friendly forum to discuss all religions in a friendly surrounding.

    Your voice is missing! You will need to register to get access to the following site features:
    • Reply to discussions and create your own threads.
    • Our modern chat room. No add-ons or extensions required, just login and start chatting!
    • Access to private conversations with other members.

    We hope to see you as a part of our community soon!

How do I build an app on Microsoft Visual Studios 2022

Ostronomos

Well-Known Member
In my attempts to create an app for Android using a windows compiler the compiler says that I need to write a preprocessor code. Why? This isn't C# it's C++.

It also says that using std::vector is an invalid std.

As well, int main is an invalid global directive.

I was trying to write a code using a vector container and I dereferenced the iterator on an empty container. In the appropriate sequence of code.

Can someone please tell me what I am doing wrong?
 

Brickjectivity

wind and rain touch not this brain
Staff member
Premium Member
I can't code in C++, but I do know that C++ has a preprocessor. It is not the same preprocessor used by C#. With C++ this happens every time you compile: first the preprocessor goes through your code expanding macros and also putting in complete files in the place of your include lines. Only then does the compiler actually begin to compile. Its possible that the preprocessing and compilation are done by the same program, but they are definitely two separate steps. I don't know more than that.
@Ostronomos
 

Mister Emu

Emu Extraordinaire
Staff member
Premium Member
@Ostronomos

I code in C++ as a hobby. Yes, C++ has preprocessor directives. For instance to use a vector, you need to include the vector header file.

#include <vector>

Is necessary as part of your preprocessor coding.
 

Ostronomos

Well-Known Member
I can't code in C++, but I do know that C++ has a preprocessor. It is not the same preprocessor used by C#. With C++ this happens every time you compile: first the preprocessor goes through your code expanding macros and also putting in complete files in the place of your include lines. Only then does the compiler actually begin to compile. Its possible that the preprocessing and compilation are done by the same program, but they are definitely two separate steps. I don't know more than that.
@Ostronomos

Can you tell me what a preprocessor directive looks like? I include the hashtag before the word include? My book uses SALES_DATA as an example. Are there others?
 

Brickjectivity

wind and rain touch not this brain
Staff member
Premium Member
Can you tell me what a preprocessor directive looks like? I include the hashtag before the word include? My book uses SALES_DATA as an example. Are there others?
I don't remember.

If you just want to code in C++ rather than write a fresh new compiler for it then don't worry about macros and preprocessor directives. You need the include directive, but most directives you don't need. Include is simple. It appends or inserts the contents of one file into another and does this before compiling takes place.

You are looking for help with writing macros. If you can get help writing macros, that is going to help you with preprocessors. Preprocessors use macros, and preprocessor directives are related to macro languages. Check your book to see if it talks about macro programming. Macros are not at all like C++. They are recursion based languages which focus upon text processing of recursively defined structures (such as C code).

If you have a programming book about C++ there may be something about the preprocessing directives in the appendix or possibly something about macros. When talking about preprocessors you are leaving 'Programming' and getting interested in 'Computer Science', and so the materials become more abstract and lengthy. That is why your book probably does not talk about them very much. Many books about this assume that compilers fascinate you and that you want to write one or several, just for fun. It is assumed that you know about finite state machines and are interested in the provability of code and its big O and lexers and tokenizers and code trees and LLVM language. All of that is chipmunk language to me. I'm interested in using computers not in becoming one.
 

Mister Emu

Emu Extraordinaire
Staff member
Premium Member
Can you tell me what a preprocessor directive looks like? I include the hashtag before the word include? My book uses SALES_DATA as an example. Are there others?
The include directive, for vectors is:

#include <vector>

Given your questions, you seem entirely new to C++. There are a lot of free resources for C++, I would heavily suggest investing some time into learning the language before trying to tackle developing an Android application.
 
Top