x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

C++ USTRUCT build problems

I am trying to create a simple USTRUCT that includes multiple property values. For testing, I created a dummy struct looking like this:

 USTRUCT()
 struct FSomeInformationStruct
 {
     GENERATED_BODY()
     UPROPERTY()
     int32 someInt;
 
     //Constructor
     FSomeInformationStruct()
     {
         someInt = 5;
     }
 };

Building the solution with VS2017 Community, I run into several errors (see below). I later copy-pasted the USTRUCT example code by Rama which resulted in the same errors (code here in the Core Syntax section)

I looked through multiple other tutorials and could not find what is wrong with my usage of USTRUCT. Still, looking at the errors it seems to me as if I understood it wrong. Since I just started using C++ aside of Blueprints, I do not have much experience so far.

I also tried restarting VS, UE Editor and the PC.

Errors (lines match 1:1 with provided code above): Errorlist by VS

Product Version: UE 4.21
Tags:
errors.png (14.8 kB)
more ▼

asked Jan 05 '19 at 10:15 AM in C++ Programming

avatar image

mistercokes
1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

There were 2 problems with my code:

  1. I needed to include the "generated" fiile ([filename].generated.h) at the beginning of the header file

  2. Using a separate header file did not work, I needed to put this struct in the project header file ([projectName].h)

The following code works for me (stored in the file "AztecsProject.h"):

 #pragma once
 
 #include "AztecsProject.generated.h"
 
 USTRUCT()
 struct FSomeInformationStruct
 {
     GENERATED_BODY();
 public:
     UPROPERTY()
         int32 someInt;
 
     //Constructor
     FSomeInformationStruct()
     {
         someInt = 5;
     }
 };



more ▼

answered Jan 05 '19 at 04:58 PM

avatar image

mistercokes
1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question